-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
🔎 Search Terms
unique symbol widening
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
const u = Symbol();
const a7 = u as typeof u // widened to symbol🙁 Actual behavior
a7 is symbol
🙂 Expected behavior
a7 has typeof u
Additional information about the issue
This issue is a huge problem for isolated declarations as it breaks the assumption that in an expression const o = a as T we can always use T as the type of o. This is also inconsistent with the way similar expressions work for string/number literal types (ex)
Similar issues:
unique symboltype lost after property is extracted from an object #43657 - Widening on return type not on variable declaration- Explicitly annotated unique symbols are widened in return positions #55361 - Similar, explicitly typed variable is widened
- Symbol type is incorrectly generalized when used as a property value of an object literal #36876 - Widening when assigning from object property (but no assertion)
unique symbols from the globalSymbolConstructorwiden way too eagerly #53276
rauschma, brandongit2 and alker0
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript