In VS Code Can I Validate my Javascript But Ignore a Specific Typescript Error?

VS Code's JavaScript type checking is powered by TypeScript. The errors you are seeing in your JS files are not TypeScript language errors, they are the TypeScript engine saying: "Hey this JavaScript code looks like it is invalid". The TypeScript engine tries to understand JavaScript as well as possible, but JavaScript's dynamic nature can sometimes trip it up and you may need to help it along with some JSDoc annotations .

So ideally you should address these errors. If this is not possible, you can suppress the errors using a // @ts-ignore comment on the line above the error (this is offered as a quick fix for the error)

This TypeScript feature request also tracks the ability to suppress specific error codes.


This could be a red herring, but are all your errors JSX related? TypeScript can handle JSX (in *.tsx ot *.jsx files) if you specify the factory to use for the JSX. The error looks like TS can't find the factory class (so it's got <Foo> and doesn't know what to pass it to). Typically this will be something like (the settings say React, but they're the same for Preact or other JSX libraries):

"compilerOptions": {
    "jsx": "react",
    "jsxFactory": "probably the same as transform-react-jsx setting in your plugins"
}

There's much more on that in the TS docs.

Generally I find it best practice to fix TS errors before JS anyway, but that isn't always practical, so another option is adding // @ts-ignore on the preceding line or // @ts-nocheck to skip type checking in the file.

// @ts-ignore is really intended for this kind of situation, but it's not a long term fix - you're upgrading, you know it works, you just need TS to skip the failing check for now. But, when you know the code works and TS is missing a definition somewhere it can be the right patch.