0

I am not enable typescript in my react project , and I just import optional chain to my project,it works but vscode keep gaving me an syntax error. I have checked all my instlled extentions, no tslint. so I don't know where the error comes from and how can I disabled this syntax checking?

enter image description here


update:

VS Code 1.41 supports optional chaining in both JavaScript and TypeScript files. This support includes syntax highlighting and IntelliSense.

https://stackoverflow.com/a/58530234/11454633

this resolved my problem.just upgrade vscode to the latest version

Community
  • 1
  • 1
Shinji035
  • 331
  • 2
  • 6
  • 17

1 Answers1

4

Inside vscode ctrl + p / command + p (Win/Mac)

>open settings (JSON)

Add to setting.json

{
  ... // other rules
  "typescript.validate.enable": false,
}

Update: If you are using typescript, directly set it as above is good enough.

For javascript, refer to link from comment, thanks

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

The files are JS so it's "Javascript validation". But this validation is done via the underlying Typescript engine. Could be a bit confusing.

keikai
  • 14,085
  • 9
  • 49
  • 68
  • thanks for your answer , but this not works for me. in fact I have tried : `"javascript.validate.enable": false` and it wroks. from this answer:https://stackoverflow.com/questions/50823743/disable-tslint-in-vscode. – Shinji035 Mar 03 '20 at 03:51
  • Have you defined the type or interface for variable test? – devspeter Mar 03 '20 at 03:53
  • @devspeter no I don't becasue I am not using typescript – Shinji035 Mar 03 '20 at 03:57