🔎 Search Terms
unique symbol widening
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
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:
@Andarist perhaps #54778 also fixes this?
🔎 Search Terms
unique symbol widening
🕗 Version & Regression Information
⏯ Playground Link
Playground Link
💻 Code
🙁 Actual behavior
a7issymbol🙂 Expected behavior
a7hastypeof uAdditional 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 Twe can always useTas the type ofo. 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 declarationunique symbols from the globalSymbolConstructorwiden way too eagerly #53276@Andarist perhaps #54778 also fixes this?