3

I'm using import * as ts from "typescript"; to import typescript in a .ts file.

The file runs fine, but VS Code is telling me Cannot find module 'typescript'. ts(2307).

Is there any way to suppress this problem?

Edit: the file can be compiled and run successfully

7
  • Is typescript installed as a global package? Commented Apr 24, 2020 at 16:18
  • @Saddy Yes, it was installed with -g. Might be something else wrong Commented Apr 24, 2020 at 16:21
  • Try stackoverflow.com/questions/37548734/… Commented Apr 24, 2020 at 16:22
  • @Saddy running tsc file.ts doesn't throw any error... The error only shows in VS Code's Problems tab Commented Apr 24, 2020 at 16:28
  • Sorry about that, this may be able to help: stackoverflow.com/questions/42632215/… Commented Apr 24, 2020 at 16:29

2 Answers 2

10

You want to change these two settings in VS Code's settings.json:

"typescript.validate.enable": false,
"javascript.validate.enable": false,

Source

Sign up to request clarification or add additional context in comments.

Comments

1

To make the previous solution more clear.

Find Edit in VS Preferences/Settings settings.JSON in ESLint or TSLint or Typescript

settings.json example

{
    "javascript.format.enable": false,
    "typescript.validate.enable": false,
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.