2
I am studying Typescript classes through official documentation: https://www.typescriptlang.org/docs/handbook/classes.html. I used exactly the same example code as the documentation:
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
let greeter = new Greeter("world");
However, when trying to execute the command tsc greeter.ts
to compile the above code, I am getting the following error:
\greeter.ts(13,5): error TS1005: ';' expected.
What is wrong?
I couldn’t reproduce the problem (I can’t paste the code URL to see). Put here and see: https://www.typescriptlang.org/play/index.html
– Maniero
Here worked correctly, tries to reinstall the
node-typescript
. Take a look to see if you are getting the right file too, because the code you put only has 11 lines and it is giving error on line 13.– JuniorNunes
Running the Tsc -v command gives the following result: Version 1.0.3.0. It already rode npm update typescript and npm install -g typescript@latest, but the version does not update. I am doing this test on a Windows 7 computer, it may have some relationship?
– Marcell Alves