I’m having issues with ts error in my .js file when I don’t have any typescript environment installed, both locally & globally. I tried something like "javascript.validate.enable": false
but I don’t want to use it, since it removes all error checks.
Here is my simple code:
//Part 1
function greeting() {
return "Good Morning!";
}
let message = greeting;
message();
greeting();
//Part 2
function greeting() {
return "Good Morning!";
}
function printMessage(anfunction) {
console.log(anfunction());
}
printMessage(greeting);
//Part 3
function greeting() {
return function () {
return "Good Morning!";
};
}
let anFunction = greeting();
let message = anFunction();
Here is .ts error:
Cannot redeclare block-scoped variable 'message'.ts(2451)
let message: {
(): string;
(): string;
(): () => string;
}
I appreciate your help.
2
Answers
I realised it has nothing to do with TypeScript. I have ESLint plugin enabled, so it simply displays them as ts error...
You use in Part3
let message = ...
, so you redeclare a let-variable.You can set message like
message = ...