-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
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
pastelmind
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed