Closed
Description
TypeScript Version: 3.0.0-dev.20180530
Search Terms:
unique symbol, property, dynamic class creation
Code
const create = () => {
const prop = Symbol();
return {
cls: class A {
public [prop]: string = 'str'; // works as expected
},
prop,
};
}
const { cls, prop } = create();
class B extends cls {
public [prop]: string = 'test'; // Error: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.
}
Expected behavior:
No error.
Actual behavior:
When unique symbol
is returned from function, it becames symbol
that forbids working with class properties defined inside the function as well as class itself.
Playground Link:
Link
Related Issues:
Didn't find any