-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[Feature request] sort literals in .d.ts #32224
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
Comments
Related: #29255 If you implement this, you'll break my compile-time tests again =( |
This is labeled |
@fatcerberus This is just requesting that d.ts emit sorts the union right before printing it. It wouldn't affect the checker itself. @AnyhowStep but then it would be the last time??? |
Oh, right. I hecked up. |
@tp It's almost certainly the same, since that difference is probably from types getting created in different order for |
If we're sorting string literals, can we also sort all the other literal types? Maybe even unique symbols. I just had another compile-time test break because the order of execution caused some union type to switch elements around. |
@AnyhowStep good idea |
The fix I made, #44614, is too slow for big projects. I think the only way we could ship this would be to sort types on union creation. |
Search Terms
Suggestion
sort string literal in .d.ts
Use Cases
avoid string literal random change order when source code didn't change
and make code history is more easy read
in this issue thread
string literal
is mean =>"a" | "c" | "b"
this not only happen on
Record
, it has chance happen at all type is auto create by typescript emit withstring literal
Examples
current .d.ts output
in this request
Checklist
My suggestion meets these guidelines:
Maintainer's note [@sandersn]: To implementers: When you implement this, be sure to sort other literal types too. Consider sorting other things, like symbol, by the order of their string representation.
The text was updated successfully, but these errors were encountered: