0

Good afternoon! I ran into such a problem that vscode began to highlight the correct code in red. When using the union operator '??' or when using optional chaining '?.' The code builds normally, there are no errors in the console, only vscode highlights the code, when hovering, an error pops up: '[ts] Expected expression'

This problem arose after I switched to a new computer, on the old computer this problem did not occur with the same code. The same extensions are installed on the new computer, the only difference with the old computer is the version of vscode itself and the version of the installed extensions.

For now, I've temporarily disabled typescript code checking in the vscode settings with "typescript.validate.enable": false,

but this approach seems wrong to me, because I want the code to be checked, but at the same time not highlighted in red using the union operator '??' or when using optional chaining '?.'

1
  • Make sure that TypeScript and VSCode are as up-to-date as possible first, ?? and ?. syntax is a bit new Commented Feb 24, 2022 at 5:21

2 Answers 2

1

Make sure you're using the correct TypeScript version in VSCode. Press Ctrl + Shift + P, then type and select "TypeScript: Select TypeScript version..." and select the latest version.

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

Comments

0

If your VS Code has tslint, you need to disable it.

1 Comment

I think this is incorrect. TS errors are highlighted via a different mechanism. I've disabled my linter and still see them

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.