13

My issue is that I cannot display typescript errors in editor using eslint and @typescript-eslint (on VSCode for MacOs).

Eslint errors are showing but not type errors as shown on this screenshot (tsx file) example of type error not showing

Here the issue about unused variable is displayed but the type error when calling typedFunction is not. If I run tsc in my terminal the error will raise.

Eslint extension is installed my VSCode editor. Here is my .eslintrc :

{
  "parser": "@typescript-eslint/parser",
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "react-app",
    "prettier",
    "prettier/@typescript-eslint",
    "prettier/react"
  ],
  "plugins": [
    "import",
    "prefer-object-spread",
    "prettier",
    "react",
    "@typescript-eslint"
  ],
  "env": {
    "browser": true,
    "es6": true,
    "node": true
  },
  "globals": {
    "alert": true,
    "document": true,
    "localStorage": true,
    "navigator": true,
    "window": true,
    "HTMLElement": true
  },
  "rules": {
    "prettier/prettier": "error",
    "import/extensions": 0,
    "import/no-extraneous-dependencies": [
      "error",
      {
        "devDependencies": true,
        "optionalDependencies": false,
        "peerDependencies": false
      }
    ],
    "import/no-unresolved": 0,
    "import/prefer-default-export": 0,
    "prefer-object-spread/prefer-object-spread": 2,
    "react/destructuring-assignment": 0,
    "react/jsx-filename-extension": [1, { "extensions": [".ts", ".tsx"] }],
    "react/no-array-index-key": 2,
    "react/prefer-stateless-function": 0,
    "react/prop-types": 0,
    "react/require-default-props": 0,
    "@typescript-eslint/explicit-function-return-type": 0,
    "@typescript-eslint/explicit-member-accessibility": 0,
    "@typescript-eslint/camelcase": 0,
    "@typescript-eslint/interface-name-prefix": 0,
    "complexity": ["error", 8],
    "max-lines": ["error", 200],
    "max-depth": ["error", 3],
    "max-params": ["error", 4]
  }
}

I tried removing all VSCode extensions, uninstalling VSCode, reboot my computer but nothing worked. My VSCode version is 1.46.0

4
  • You need tslint for typescript. Commented Jun 12, 2020 at 18:05
  • 1
    no, you can use eslint for typescript. @OP can you check what Typescript version VSCode is using and can you try other version? in the command palette select : Typescript: Select Typescript Version Commented Jun 12, 2020 at 18:40
  • Thanks for your answer. When i open the command palette an type Typescript no results are returned. I'm on MacOs is it maybe the reason ? Commented Jun 13, 2020 at 16:18
  • But the version in my repository (installed in node_modules) is Version 3.9.3 and globally my version is Version 3.9.5 Commented Jun 13, 2020 at 16:27

4 Answers 4

35

In your VSC's Extensions panel, type "@builtin" and look for "TypeScript and JavaScript Language Features" in the "Features" section. It is most probably disabled. Enable it and restart your VSC. As suggested by Matt Bierner from here.

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

6 Comments

I have tried to get "started" with TS for many years, but never got passed this step! This worked perfectly.
Thank you! My "TypeScript and JavaScript Language Features" was already enabled, but not working, so I disabled it, reloaded, and re-enabled it. Worked like a charm!
This did it for me! Good answer!
Thanks for this! The ole "turn it off and back on again" approach fixes another bug. 🎉
I had the both typescript @builtin features enabled but was still not getting the errors shown when hovering. Turns out I had "typescript.validate.enable": false,' in my settings.json and this was the culprit. Removing that line got it working properly...
|
1

In my case I had typescript properly configured and working in the past, but it regressed without me touching any configs. My solution was to open up the command palette, and run Typescript: Restart TS Server. Errors came back in my problems pane after that.

Comments

0

VSCode does not have an in-built typescript linter. https://code.visualstudio.com/docs/languages/typescript#_linters

Install ESlint extension from the marketplace for JS and TS lint error. If it is already installed, and typescript is introduced at later stage, just reinstall ESlint extension and restart the VSCode

Comments

-2

You need to add a tsconfig.json file to your project, it would work. Something like this

{
  "exclude": ["node_modules", "node_modules/**/*"],
  "compilerOptions": {
    "baseUrl": "./",
    "lib": ["es5", "es6", "dom", "es2018.promise"],
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "./build",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": false,
    "strict": true,
    "strictPropertyInitialization": false,
    "skipLibCheck": true, 
    "suppressImplicitAnyIndexErrors": true
  }
}

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.