In my Visual Studio Code, I have written just one line of code in my ex1.ts file:
let n: number = 10;
Upon compiling using the command tsc ex1.ts, the compiler successfully generates the ex1.js file. However, VSC promptly displays an error in the .ts file:
Cannot redeclare block-scoped variable 'n'.ts(2451)
ty1.js(1, 5): 'n' was also declared here.
VSC is indicating that there is another variable 'n', although it exists in the .js file rather than the .ts file. I thought TypeScript was meant for compiling .js files with strict typechecking. Why does it cause a conflict between unrelated .js and .ts files?
The error vanishes when I remove the .js file. These files are located within a straightforward "exercises" folder.
What could be a solution to this issue?