microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.85k stars 594 forks source link

[api-extractor] Support Typescript 5.5 #4805

Open colinaaa opened 3 months ago

colinaaa commented 3 months ago

Summary

After upgrading to the latest Typescript version (5.5.2) with isolatedDeclarations enabled, the api-extractor failed to run.

> api-extractor run --verbose

api-extractor 7.47.0  - https://api-extractor.com/

Using configuration from ./api-extractor.json

ERROR: Error parsing tsconfig.json content: Unknown compiler option 'isolatedDeclarations'.

Repro steps

  1. Create a new TS 5.5 project.
  2. Enable isolatedDeclarations
  3. Run api-extractor

Expected result:

No error.

Actual result:

Failed to run api-extractor.

Details

As mentioned in docs, this could be fixed by upgrading the TypeScript compiler in api-extractor.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version? 7.47.0
Operating system? Mac
API Extractor scenario? reporting (.api.md)
Would you consider contributing a PR? Yes
TypeScript compiler version? 5.5.2
Node.js version (node -v)? 20.15.0
iclanton commented 3 months ago

@colinaaa - Would you be willing to raise a PR making the necessary changes?

colinaaa commented 3 months ago

I tried to upgrade to TS 5.5. And the following errors showed up:

  [build:typescript] common/temp/default/node_modules/.pnpm/@typescript-eslint+typescript-estree@6.19.1_typescript@5.5.2/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts:17:3594 - (TS2694) Namespace 'ts' has no exported member 'InputFiles'.
  [build:typescript] common/temp/default/node_modules/.pnpm/@typescript-eslint+typescript-estree@6.19.1_typescript@5.5.2/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts:17:3610 - (TS2694) Namespace 'ts' has no exported member 'UnparsedSource'.
  [build:lint] eslint/eslint-plugin/src/hoistJestMockPatterns.ts - Parsing error: Cannot use 'in' operator to search for 'illegalDecorators' in 93

Looks like it also needs https://github.com/typescript-eslint/typescript-eslint/issues/8996 to work with TS 5.5.

Should I just upgrade typescript-eslint-related dependencies from ~6.19.0 to 7.14.1(the version that supports TS 5.5)?

colinaaa commented 3 months ago

Also, the Simplified Reference Directive Declaration Emit change of TS 5.5 seems to cause errors for tests.

E.g.:

In build-tests/api-extractor-test-01/dist/api-extractor-test-01.d.ts:

- /// <reference types="jest" />
- /// <reference lib="es2015.symbol.wellknown" />
- /// <reference lib="es2018.intl" />

These Reference Directive Declaration are eliminated, which makes api-extractor-test-02 failed:

==> Starting build.js for api-extractor-test-02
---> node node_modules/typescript/lib/tsc
../api-extractor-test-01/dist/api-extractor-test-01.d.ts(59,24): error TS2503: Cannot find namespace 'jest'.