0

I've followed this thread to solve the problem

TypeScript error TS1005: ';' expected (II)

I installed Typescript as global but it always saved at C:/Users/MyName/AppData/Roaming/npm

I'm not sure if this should be global so I used npm update then npm uninstall -g typescript then npm install -g typescript@latest.

My environment last variable has

C:\Users\Mostafa\AppData\Roaming\npm;

I tried to execute the code from the source so I used in the VS Code

cd C:\Users\Mostafa\AppData\Roaming\npm\node_modules\typescript\bin

then

tsc C:\Users\Mostafa\HelloWorld\src\index.ts

Also didn't work

Majid Hajibaba
  • 3,105
  • 6
  • 23
  • 55
Mostafa Ezzat
  • 29
  • 1
  • 11
  • Hi Mostafa please include your typescript code and all errors you encounter. – Mohammad Mostafa Dastjerdi Jul 27 '21 at 14:09
  • I'm totally new to typescript but these snippets from a book `addTodo(task: string): number { while (this.getTodoById(this.nextId)) { this.nextId++; } this.todoItems.push(new TodoItem(this.nextId, task)); return this.nextId; };` and this the error `./../../HelloWorld/src/todoItem.ts:32:30 - error TS1005: ';' expected. 32 addTodo(task: string): number {` – Mostafa Ezzat Jul 27 '21 at 14:27
  • 1
    Two things I found in your code: 1. If you are creating a function you need to place `function` at beginning of your function definition `function addTodo(...){...}` 2. You don't need semicolon at the end of your function definition – Mohammad Mostafa Dastjerdi Jul 27 '21 at 14:31
  • @MMD Yeah, thanks it ran, it's just first time i write typescript code and i'm learning from Essential TypeScript : From Beginner to Pro and it starts with some projects Thank you it wasn't the compiler problem – Mostafa Ezzat Jul 27 '21 at 14:41

0 Answers0