Closed
Description
TypeScript Version: 2.5.2
Code
type Constructor<T = {}> = new (...args: any[]) => T;
function Mixin<T extends Constructor>(Base: T) {
return class extends Base {
NonArrowFunction() {
console.log("Non Arrow Function");
}
ArrowFunction = () => {
console.log("Arrow Function");
}
}
}
class A extends Mixin(Object) {
constructor() {
super()
// No runtime errors
this.ArrowFunction();
// Runtime error in es5 export
this.NonArrowFunction();
}
}
new A();
Expected behavior:
No runtime error when compiled with --target es5
and run with latest node version.
Actual behavior:
TypeError: _this.NonArrowFunction is not a function
at new A (C:\Users\Daniel\Desktop\mixines5.js:31:15)
at Object.<anonymous> (C:\Users\Daniel\Desktop\mixines5.js:36:1)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
The runtime error does not happen when mixing into an empty class as opposed to Object
.