Closed
Description
TypeScript Version:
1.8.7
Code
// A self-contained demonstration of the problem follows...
const test = Symbol('name');
class Foo {
constructor() {
console.log('Foo constructor');
}
}
Foo[test] = 'testing a symbol';
class Bar extends Foo {
constructor() {
super();
console.log('Bar constructor');
}
}
let b = new Bar();
console.log(Bar[test]);
Expected behaviour:
Should output
Foo constructor
Bar constructor
testing a symbol
Actual behaviour:
Actual output is
Foo constructor
Bar constructor
undefined
This is because the __extends helper uses hasOwnProperty
to check for properties to be copied over. Symbols are not properties, so they are never copied.
This works correctly with native ES6 classes, and with Babel's _inherits helper (using Object.setPrototypeOf rather than copying properties manually).