Closed
Description
TypeScript Version: 3.7.2
Search Terms: useDefineForClassFields, constructor
Code
class Test {
constructor(public readonly something: number) { }
}
const k = new Test(5);
Expected behavior: I expect k.something
to be 5
Actual behavior: k.something
is undefined, cause TS:
- writes the value to the property (as it was before)
- and then rewrite it (with
writable: true
, I think it is bug too) tovoid 0
class Test {
constructor(something) {
this.something = something;
Object.defineProperty(this, "something", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
}
}