rushstack
rushstack copied to clipboard
[api-extractor] Move "typescript" from dependencies to peerDependencies
Summary
In @microsoft/api-extractor there is a dependency on typescript, and this PR converts that from a hard dependency to a peerDependency, so the client can supply their own typescript version instead of being forced to use the one that api-extractor chooses.
Details
"typescript" was removed from dependencies and added to peerDependencies, as well as devDependencies so the package can still locally use a copy of typescript when building.
How it was tested
Unsure
Could you provide some detail about the problem scenario that you're trying to solve? (Is it merely that API Extractor's typescript
dependency needs to be upgraded?)
so the client can supply their own typescript version instead of being forced to use the one that api-extractor chooses.
This is unlikely to work reliably. API Extractor installs its own specific version of TypeScript because it accesses internal compiler APIs that can get broken between major releases of the TypeScript compiler. Also, API Extractor's logic analyzes the compiler's abstract syntax tree (AST) whose structure changes whenever new language features are installed. Often, upgrading to a newer compiler will require code changes to API Extractor.
From a design perspective, API Extractor analyzes your library the way an external consumer would (by looking at your lib/*.d.ts
files using the latest compiler), not the way your toolchain does (by looking at your src/*.ts
files using your own compiler version and tsconfig.json context).
Came here to suggest something similar because the package vite-plugin-dts
utilizes api-extractor
however the hard dependency on typescript breaks typescript 4.9 type generation, and we can't override it using yarn resolutions due to the ~4.8.4
dependency. But it seems this would be a bigger release for this package to support 4.9?
Relevant issue raised: https://github.com/microsoft/rushstack/issues/3890
But it seems this would be a bigger release for this package to support 4.9?
No, often that is quite easy actually. I can investigate on Monday and follow up.
I'm also interested in this PR for the vite-plugin-dts
reasons mentioned. If there is anything I can do to help please let me know.