microsoft/rushstack

[api-extractor] Support Typescript 5.4

davidlj95 opened this issue ยท 6 comments

Summary

After upgrading a project to latest Typescript version (5.4.2), can't run API Extractor any more as it requires a toolchain Typescript older than 5.3.3.

As stated in docs opening an issue to request the Typescript version update ๐Ÿ˜ƒ

* Will try a PR later if have some time, seems last update to support 5.3 didn't require much changes

The message for sake of completeness:

*** The target project appears to use TypeScript 5.4.2 which is newer than the bundled compiler engine; consider upgrading API Extractor.
Warning: You have changed the public API signature for this project. Please copy the file "/home/runner/work/ngx/ngx/projects/ngx-meta/api-extractor/temp/ngx-meta.api.md" to "/home/runner/work/ngx/ngx/projects/ngx-meta/api-extractor/ngx-meta.api.md", or perform a local build (which does this automatically). See the Git repo documentation for more info.

API Extractor completed with warnings

Repro steps

N/A

Details

N/A

Standard questions

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

Question Answer
@microsoft/api-extractor version? 7.42.3 (latest when writing this)
Operating system? Linux
API Extractor scenario? N/A
Would you consider contributing a PR? Yes
TypeScript compiler version? 5.4.2
Node.js version (node -v)? 20.11.1

@octogonz has handled these in the past, although I'm sure he'd appreciate some help!

I read the Announcing TypeScript 5.4 release notes, and none of those changes sound like they would impact API Extractor's ability to analyze .d.ts files. ๐Ÿ‘

Let me create a PR to upgrade the version and we'll see if any internal APIs got broken.

Here's a PR: #4587

Everything built but there are some incorrect .d.ts rollups in 05c3afa that I think are caused by changes in the formatting of the compiler output. We need to investigate that.

Awesome! Thanks @iclanton & @octogonz โค๏ธ

Everything built but there are some incorrect .d.ts rollups in 05c3afa that I think are caused by changes in the formatting of the compiler output. We need to investigate that.

The prop2 appearing in that diff is actually caused by the TypeScript compiler, not API Extractor: microsoft/TypeScript#57841

However I still need to investigate why it didn't appear in the .d.ts rollup prior to TypeScript 5.4.

However I still need to investigate why it didn't appear in the .d.ts rollup prior to TypeScript 5.4.

The compiler was improved to avoid emitting these parameter destructuring aliases in TypeScript 4.8 (576d198 in our repo), however that turned out to cause regressions in some edge cases, thus TypeScript 5.4.2 reverted this change with microsoft/TypeScript#57020. (Interestingly, the TypeScript maintainers thought these edge cases probably could be handled, however the computational cost would not have justified the benefit. Of course, API Extractor has different requirements from a compiler, e.g. if we were motivated we could consider implementing this feature for .api.md and .api.json but not the .d.ts rollup.)

In short, the diff in 05c3afa is by design.