0

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'

TS Error

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.

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.