TypeScript behavior
I'm doing some simple JavaScript coding exercises in TS and have come across this odd behavior I haven't encountered before.
I have only the following code:
I get the following error:
Did a really quick Google search, and it seems to be because it's in the global scope. So I put it in a function and it works.
Now, when I try this code only and by itself:
I get no such error. Why is that?
2 Replies
Sometimes the TS server gets hung up, try to restart it
It was a linter error, but I actually didn't try running it lol, let me check now
It runs in ts-node lol
Ohhh I see, it's because my vscode linter is somehow tied to my workspace (folder) rather than each file, so because I declared it in another file inside my workspace, it's throwing a warning. That's weird
Thanks!