🔎 Search Terms
widening return unique symbol
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.3.0-dev.20230814&ssl=6&ssc=2&pln=1&pc=1#code/KYDwDg9gTgLgBAYwgOwM7xsdcC8cDKAngLYBGEANgBQCUAUHaJLHAGYCuyCMAlim8lpwA3nTjjEKbAEMKPaagBccGITDAIrFVnh5M6ANxiJUYDHZRkcWfNR0AvkA
💻 Code
export const test = Symbol()
export function fn() {
const alias: typeof test = test;
return alias
}
🙁 Actual behavior
this declaration file is emitted:
export declare const test: unique symbol;
export declare function fn(): symbol;
🙂 Expected behavior
this declaration file to be emitted:
export declare const test: unique symbol;
export declare function fn(): typeof test;
Additional information
getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded calls getWidenedLiteralLikeTypeForContextualType and that calls getWidenedUniqueESSymbolType when there is no contextual type provided.
some issues that are (partially~) related:
#32242
#35896 (comment)
#36876
🔎 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