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] Union types extracted from declaration files are unstable #4646

Open
h-a-n-a opened this issue Apr 15, 2024 · 0 comments
Open

Comments

@h-a-n-a
Copy link
Contributor

h-a-n-a commented Apr 15, 2024

Summary

The union types extracted from TypeScript declaration files are possibly unstable.

In rspack, we run API checks using api-extractor to ensure the API change is correct. The result shows the union type is not ordered (or sorted), causing the snapshot being not usable. The result of an diff command for both etc and temp file.

image

Repro steps

It's hard to reproduce as this is related to some internal declaration inlining logics.

Expected result:

The union output should be stable.

Actual result:

The union output is not stable.

Details

As what has been discussed in microsoft/TypeScript#17944 issue, tsc does not seem to provide the stable output for the union type. Potential fix might be sorting the output of the union types like microsoft/TypeScript#32224, but I don't know whether it's good to ship it in on the tsc side or on the api-extractor side. If you have any possible recommended solution on this one, please let me know.

Possible solution: Maybe we could sort the dts before passing to the api-extractor using formatters like https://typescript-eslint.io/rules/sort-type-constituents/.

Standard questions

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

Question Answer
@microsoft/api-extractor version? 7.43.1
Operating system? MacOS
API Extractor scenario? reporting
Would you consider contributing a PR? Yes
TypeScript compiler version? 5.0.2
Node.js version (node -v)? 18.16.0
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

No branches or pull requests

1 participant