Issue
I'm going through the TypeScript tutorial here: https://www.typescripttutorial.net/typescript-tutorial/typescript-hello-world/
And I've got this in my app.ts file:
let message: string = 'Hello, TypeScript!';
let heading = document.createElement('h1');
heading.textContent = message;
document.body.appendChild(heading);
But on VS Code I'm getting a 'Cannot redeclare block-scoped variable 'message'.' error message after compiling. I've changed the variable name to something less generic, but I still get the same error.
Does anyone know why? Have I missed something obvious or is it an issue with my VS code set up? Pretty frustrating that I'm struggling on step 1 of the tutorial haha, any help is much appreciated!
*Edit: I even get it when I do a simple console.log: https://i.stack.imgur.com/XWNuE.jpg
Solution
This post helped solved my issue: https://stackoverflow.com/a/68153061/9396175
Seems like it's an issue with VS Code and having the ts and js files open at the same time.
Answered By - SamuCoop
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.