Open
Description
TypeScript Version: 3.2.0-dev.20181011
Search Terms: computed property expression
Code
const classes = [];
for (let i = 0; i <= 10; ++i) {
classes.push(
class A {
[i] = "my property";
}
);
}
for (const clazz of classes) {
console.log(Object.getOwnPropertyNames(new clazz()));
}
Expected behavior: The log statements indicate that each class in classes
has a different property name (i
should be evaluated at the time of the class evaluation and all instances of that class should have a property name corresponding to that evaluation of i
).
Actual behavior: Compiled code logs:
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]
[ '10' ]