Reputation: 845
So I'm working through the 'TypeScript in 5 Minutes':
https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html
But I keep getting error after error (not great when trying to show a colleague TS).
For example, using this example (the very first one):
function greeter(name) {
return 'Hello ' + name;
}
let user = 'Test';
console.log(greeter(user));
Even the above, extremely simple TS example gives me 2 errors.
First Error - Highlights the 'greeter' in the function declaration and says: 'Duplicate Function Declaration'
Second Error - Highlights the 'user' declaration and says: 'Cannot redeclare block scoped variable user'
I have followed these guides a few times now and never experienced this.
I have attempted disabling any Plugins I think may be conflicting with it (Prettier / ESLint) but I'm still receiving the same error.
I was originally having problems, but I identified an erronous PATH variable that was forcing TS to v 1.0.0.3 however, I have now resolved this and the correct TSC version is found.
I can't figure out why I'm receiving errors even on the very first example?
Any advice would be appreciated.
Upvotes: 0
Views: 186
Reputation: 845
Almost don't want to post this, but the issue was that as I had the .js file and the .ts file open side-by-side, they were conflicting with each other.
Having just one of the files open at once removes all the errors.
Aaaaah!
Upvotes: 1