-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad TS class translation #11605
Comments
I think it is related to useDefineForClassFields in tsconfig.json "use strict";
class Cparent {
parentVal;
constructor() {
this.parentVal = 'parent';
this.init();
}
init() { }
}
class Achild extends Cparent {
childVal;
constructor() {
super();
}
init() {
this.childVal = 'child';
}
}
const a = new Achild();
console.log(a.parentVal, a.childVal); which will give you "parent", undefined |
If I set useDefineForClassFields, the result is : "use strict";
class Cparent {
constructor() {
Object.defineProperty(this, "parentVal", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.parentVal = 'parent';
this.init();
}
init() { }
}
class Achild extends Cparent {
constructor() {
super();
Object.defineProperty(this, "childVal", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
}
init() {
this.childVal = 'child';
}
}
const a = new Achild();
console.log(a.parentVal, a.childVal); And result is But I think that the logical behavior should be this result : |
check this microsoft/TypeScript#33509 it should be considered as correct behavior in spec... |
Thanks for the ref. |
What version of Bun is running?
1.1.12
What platform is your computer?
Linux 5.15.0-107-generic x86_64 x86_64
What steps can reproduce the bug?
Considering following TS code:
What is the expected behavior?
Expected behavior when compiling with TS:
And when running:
What do you see instead?
When building with bun:
When running:
Additional information
No response
The text was updated successfully, but these errors were encountered: