https://stackoverflow.com/questions/46398916/typescr
First of all, I've already seen the other posts about error TS1005. Same error code, but totally different ;)
I was excited to try out TypeScript but was disappointed. A simple let x: number;
will generate the error TS1005 during compilation. It's not about a missing semicolon as what the error msg says, but the compiler does not recognize the let keyword. I read that maybe because of an outdated compiler. Here's my typescript version installed using npm install -g typescript
- TypeScript version: 2.5.2
- Compiler (tsc) version: 1.0.3.0
Maybe somebody can help? Thank you.
Your installation is wrong; you are using a very old compiler version (1.0.3.0).
tsc --version
should return a version of 2.5.2.
On linux, OSX, check where that old compiler is located using: which tsc
and remove it.
Try uninstalling the "global" typescript
npm uninstall -g typescript
Installing as part of a local dev dependency of your project
npm install typescript --save-dev
Execute it from the root of your project
./node_modules/.bin/tsc
answered Sep 25 '17 at 7:24
16k33 gold badges4040 silver badges7171 bronze badges
-
1
Hi sir, solved it. Thank you. The key is
which tsc
orwhere tsc
. Found out there was another version of tsc in C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\. I just removed the old one from the path. – StockUberflow Sep 25 '17 at 7:37 -
Opened an issue on github about it. – Yairopro Jan 31 '18 at 14:10
-
I was using a slightly older version of tsc which led to not existing issues. I updated the global tsc and now it is okay. – Seagull Aug 28 '18 at 12:51
9
On Windows you can have in your PATH
PATH = ...;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\; ...
remove it from PATH env, then
npm install -g typescript@latest
it worked for me to solve the
"TypeScript error TS1005: ';' expected"
You haven't the last version of typescript.
Running npm install -g typescript
, npm
checks if tsc
command is already installed. And it might be, by another software like Visual Studio. If so, npm
doesn't override it. So you have to remove the previous deprecated tsc
installed command. Run where tsc
to know its bin location. It should be in C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
in windows. Once found, delete the folder, and re-run npm install -g typescript
. This should now install the last version of typescript.
answered Jan 31 '18 at 21:11
2,2691616 silver badges2626 bronze badges