🔎 Search Terms
computed property unique symbols declaration emit
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.7.2#code/MYGwhgzhAEAq0G8BQ1XQgFzBglsaATgKZgAmA9gHYgCe0A2gEQaMC6AXNAK6U4COXIuhoBbAEbkQAbiQBfJCCIZoAD07I0DWExasO0Sl3FECM2TMXK6AXkQo09bczb6AjHKRA
💻 Code
classT{staticreadonly["t"]: unique symbol;}letx: {[T["t"]]: number;};lety={[T["t"]]: 1}🙁 Actual behavior
The type of x has an error saying: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol'
The type of y is emitted in declaration files just like the type of x and causes an error in the d.ts file
🙂 Expected behavior
The type of x should be valid. If we use a non-computed property name, the type would be valid (let x: { [T.t]: number; }, Playground Link). Declaration emit should not emit invalid code.
Additional information about the issue
Probably fixed by #60052 since the limitation on computed property names in types goes away.
🔎 Search Terms
computed property unique symbols declaration emit
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.7.2#code/MYGwhgzhAEAq0G8BQ1XQgFzBglsaATgKZgAmA9gHYgCe0A2gEQaMC6AXNAK6U4COXIuhoBbAEbkQAbiQBfJCCIZoAD07I0DWExasO0Sl3FECM2TMXK6AXkQo09bczb6AjHKRA
💻 Code
🙁 Actual behavior
The type of
xhas an error saying:A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol'The type of
yis emitted in declaration files just like the type ofxand causes an error in the d.ts file🙂 Expected behavior
The type of
xshould be valid. If we use a non-computed property name, the type would be valid (let x: { [T.t]: number; }, Playground Link). Declaration emit should not emit invalid code.Additional information about the issue
Probably fixed by #60052 since the limitation on computed property names in types goes away.