Solution :
If you look inside your class carefully, then you will realize that TypeScript will not permit a declaration of class members by
· Using var keyword
· Using let keyword
· Using const (you can use readonly on the property)
Also, if you look inside of a class then you will realize that you will be prohibited from declaring the functions by
· Using function keyword
So the correct way to write the code which you were looking for is as below :
export class MyAppComponent {
x: string = "fooo";
y: string = "barr";
fooo(): void { }
constructor(){
}
}
And clearly not the way as shown below,
export class MyAppComponent {
var x: string = "fooo";
let y: string = "barr";
function fooo(): void { }
constructor(){
}
}
Hope the above mentioned code and explanation will surely help you in clearing your doubts related to coding.