Closed
Description
TypeScript Version: 2.6.2
Code
class Ite {
[Symbol.toPrimitive](hint): number | string {
switch (hint) {
case 'number':
return 100;
case 'string':
return "100";
case "default":
return "default";
default:
return null;
}
}
}
let ite: Ite = new Ite();
/*The following code hints the errors */
console.log(ite == 100);
console.log(ite + 100);
console.log(ite * 2);
Expected behavior:
JavaScript can run normally, and display the following content at the console
false
default100
200
but typescript can't compile success. And many of the rest of the Symbol
attributes are not normally identified. Such as Symbol.species
.