2

// @ts-check

const obj = {
  str: `a string`,
};

console.log(obj.nonexistant); // no error (it should be erroring)

let num = 0; // type number
num = obj.str; // has error (good)

Why is the first issue not showing the red underline error/problem in VS Code?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
700 Software
  • 85,281
  • 83
  • 234
  • 341

1 Answers1

1

The typing is fine. I'm pretty sure this is a configuration thing. Try adding a jsconfig.json with "strict": true, or "noImplicitAny": true, in its compilerOptions field, or a tsconfig.json with the same, along with "allowJs": true, and "checkJs": true,.

starball
  • 20,030
  • 7
  • 43
  • 238