-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Description
🔎 Search Terms
widening return unique symbol
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 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
rotu, cassus and brandongit2
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