-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Explicitly annotated unique symbols are widened in return positions #55361
Copy link
Copy link
Open
Labels
Domain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Metadata
Metadata
Assignees
Labels
Domain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Type
Fields
Give feedbackNo fields configured for issues without a type.
🔎 Search Terms
widening return unique symbol
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.3.0-dev.20230814&ssl=6&ssc=2&pln=1&pc=1#code/KYDwDg9gTgLgBAYwgOwM7xsdcC8cDKAngLYBGEANgBQCUAUHaJLHAGYCuyCMAlim8lpwA3nTjjEKbAEMKPaagBccGITDAIrFVnh5M6ANxiJUYDHZRkcWfNR0AvkA
💻 Code
🙁 Actual behavior
this declaration file is emitted:
🙂 Expected behavior
this declaration file to be emitted:
Additional information
getWidenedLiteralLikeTypeForContextualReturnTypeIfNeededcallsgetWidenedLiteralLikeTypeForContextualTypeand that callsgetWidenedUniqueESSymbolTypewhen there is no contextual type provided.some issues that are (partially~) related:
#32242
#35896 (comment)
#36876