5

In my settings.json, I have:

"eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ]

Yet my typescript support isn't working. It catches the errors during runtime but doesn't show a red squiggly line (example below).

I also get an error when enabling ESLint and Prettier doesn't work when I enable ESLint:

ESLint: Failed to load parser '@typescript-eslint/parser' declared in 'template/.eslintrc.js': Cannot find module 'typescript' Require stack: - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/typescript-estree/dist/parser.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/typescript-estree/dist/index.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/parser/dist/parser.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/parser/dist/index.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/config-array-factory.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/cli-engine.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/index.j

How do I fix this problem?

enter image description here

2 Answers 2

6

The way to fix this problem is to follow these steps:

  1. Close VSCode

  2. CD into applications

/Users/<user>/Library/Application\ Support
  1. Check where VSCode folder is located (find whether it is code/ or .vscode/)
ls
  1. Delete the VSCode folder
rm -rf code/ or .vscode/
  1. Open up VSCode - there should be all your extensions there but stuff like your theme, extension settings will not be configured -

  2. Now everything (extension settings, theme, etc) will be reset

1

You can follow the steps to fix typescript

You can also try checking the TypeScript server logs to see why TSLint is not working:

  • In your VS Code user or workspace settings, set "typescript.tsserver.log": "terse"
  • Open a TS file that you believe should have TSLint enabled.
  • In the VS Code command palette, run TypeScript: Open TS Server Log.
3
  • 1
    When I do this, Prettier works and ESLint works on JS files but TS still doesn't have red lines.
    – Henry
    Commented Oct 14, 2020 at 5:41
  • I added a .eslintrc.json but it still is not giving me typescript support, only telling me to use single quotes in my typescript file
    – Henry
    Commented Oct 14, 2020 at 6:28
  • It works now, I reinstalled VSCode. Turns out I did the ESLint settings wrong at the beginning thanks for your help
    – Henry
    Commented Oct 14, 2020 at 6:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.