Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Stuart-Wilcox
Copy link

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

@octogonz
Copy link
Collaborator

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

@mfb-davidmay
Copy link

mfb-davidmay commented Jan 21, 2023

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: #3890

@octogonz
Copy link
Collaborator

octogonz commented Jan 22, 2023

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.

@corsen2000
Copy link

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.

@octogonz octogonz requested a review from dmichon-msft as a code owner April 22, 2023 19:03
@Stuart-Wilcox Stuart-Wilcox force-pushed the user/stuartwilcox/typescript-peer-dep branch from a9dacfa to 7dba2c1 Compare December 28, 2023 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: AE/AD
Development

Successfully merging this pull request may close these issues.

5 participants