-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
I have the following ES6 class
class MyClass {
constructor(){
this.myclassvar = 'abc';
}
}
When compiled/transpiled through TypeScript it generates error TS2339: Property 'myclassvar' does not exist on type 'MyClass'.
If the above code snippet is valid ES6 then TypeScript should not generate the error. The generated javascript it valid. It's just that the error scares the developers trying to use ES6 without typings.
The same ES6 class transpiles properly in BabelJS.
I know I can fix the error by declaring the variable.
class MyClass {
myclassvar;
constructor(){
this.myclassvar = 'abc';
}
}
Since TypeScript is a superset of Javascript, it should be able to handle valid ES6 without errors.
My compiler settings are
"compilerOptions": {
"target": "es5",
"module": "amd",
"declaration": true,
"noImplicitAny": false,
"noResolve": true,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
iignatov, benbieler, victorvoid, Vheissu, dfromero and 59 moreItrulia, chestercharles, pcmulder and Jackclarify
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created