[] Acquaintance TypeScript after running configure the environment Hello World compile error.

After the first contact with TypeScript, configure the environment,

Hello found even the most basic writing a World are being given, as follows:

const hello:string = "Hello World!"
console.log(hello) 

Error code is as follows:
error TS1008: Unexpected token; 'Module1, class, interface ..................

Other simple code to write again, and again an error code is as follows:

let x: [number, string];
x = [5, "abc"];
console.log(x[0]);

Error code is as follows:
Test.ts (l, 5): error TS1005: ';' expected.

 

Completely illogical error I see a look of ignorant force, and later found the problem, because TypeScript version is too low ! Use the command tsc -v, view the version number Version 1.0.3.0, as shown below:

Now it has come to the 3.x version, but the installation down or even 1.0 version.

Having identified the problem, reinstall the decisive TypeScript, but the problem is still not resolved.

Continue down the investigation found out that the environment variable configured in an older version of the path : C: \ Program Files (x86 ) \ Microsoft SDKs \ TypeScript \ 1.0

The change removed from the path of the Path, with npm command to reinstall the TypeScript, version finally solved the problem:

 

Recompile ts file, the problem was solved!

 

Guess you like

Origin www.cnblogs.com/SunboyL/p/11517304.html