rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] Update TypeScript version from 5.4.2 to latest

Open jawj opened this issue 1 year ago • 8 comments

Summary

I'm using the latest TypeScript version. When I run api-extractor, I see this:

Analysis will use the bundled TypeScript version 5.4.2
*** The target project appears to use TypeScript 5.7.2 which is newer than the bundled compiler engine; consider upgrading API Extractor.

I then get various errors related to the TypeScript version being out of date, such as:

Warning: node_modules/subtls/index.d.ts:207:49 - (TS2315) Type 'Uint8Array' is not generic.

I can point api-extractor to the 5.7.2 type definitions, but of course it doesn't fully understand these, because it's too old.

I note this in the docs:

If the issue is that your toolchain uses a newer compiler release than API Extractor's engine, please open a GitHub issue requesting to upgrade API Extractor's compiler. We try to stay as current as possible.

So here's the issue!

jawj avatar Dec 18 '24 14:12 jawj

I'm using the ${configDir} template variable in my tsconfig.json, which was added in TypeScript v5.5. api-extractor throws the following error:

Error: Error parsing tsconfig.json content: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["${configDir}src/**/*"]' and 'exclude' paths were '[]'.
    at CompilerState.create (/my-lib/@microsoft/api-extractor/lib/api/CompilerState.js:76:19)

I assume that this is because api-extractor is still using TypeScript v5.4.2.

ocavue avatar Dec 27 '24 07:12 ocavue

@octogonz - do you have some time to take a look at this?

iclanton avatar Jan 06 '25 19:01 iclanton

This is an important fix.

In this Zulip thread we investigated an error Error: Internal Error: Unable to follow symbol for "Record" whose root cause was an outdated TypeScript compiler:

Generally it is preferable to have "useProjectTypescriptVersion": false because it provides a consistent set of files, which is basically how your .d.ts files would be seen by a library consumer that is using an older compiler. It will only fail if your code uses new syntax that is not recognized by the older compiler. That is likely with .ts files, but much less likely with .d.ts files (which are intentionally designed to maximize compatibility). So I bet you had introduced this setting earlier when you were trying to compile .ts files, and now it is no longer needed.

That said, 5.4.2 is pretty old. We really should make a PR to upgrade API Ectractor's built-in compiler version. Often this is just a one-line fix (depending on how much they changed for the internal API's and language enhancements).

octogonz avatar Jan 06 '25 20:01 octogonz

Looks like @colinaaa had started work on that in PR https://github.com/microsoft/rushstack/pull/4815

octogonz avatar Jan 06 '25 20:01 octogonz

Any solution until will be fixed ? I can't publish a pacakge because of this error. Thanks.

CosminCotulbea avatar Jan 06 '25 21:01 CosminCotulbea

Working on it today

octogonz avatar Jan 06 '25 21:01 octogonz

I've updated PR https://github.com/microsoft/rushstack/pull/4815 to 5.7.2 and resolved the build issues.

octogonz avatar Jan 07 '25 00:01 octogonz

Should this be a new issue now that we're on TS 5.9.x?

laviddichterman avatar Aug 22 '25 02:08 laviddichterman