rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] Move "typescript" from dependencies to peerDependencies

Open Stuart-Wilcox opened this issue 2 years ago • 4 comments

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

Stuart-Wilcox avatar Jan 13 '23 00:01 Stuart-Wilcox

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).

octogonz avatar Jan 13 '23 00:01 octogonz

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

mfb-davidmay avatar Jan 21 '23 04:01 mfb-davidmay

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.

octogonz avatar Jan 22 '23 21:01 octogonz

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.

corsen2000 avatar Mar 21 '23 17:03 corsen2000