Optional chaining operator support in VSCode

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

If you are using VS Code 1.41+ and optional chaining is not working as expected, try:

  • Check your installed extensions. Some of them may not yet understand optional chaining, which could cause errors or bad syntax highlighting

  • If you are using a workspace typescript version, make sure it is TypeScript 3.7+


This was still happening to me until I uninstalled the extension JavaScript and TypeScript IntelliSense

So yes, check uninstalling old plugins if you are still having this issue. Also you can try the vscode insiders version and check if this works in that one. It worked for me without doing any change.


I just resolved the issue with disabling js/ts validation in vscode json settings:

"javascript.validate.enable": false

You my need to install eslint-plugin-babel for eslint rules.

{
  "plugins": [
    "babel"
  ],
  "rules": {
    "babel/new-cap": 1,
    "babel/camelcase": 1,
    "babel/no-invalid-this": 1,
    "babel/object-curly-spacing": 1,
    "babel/quotes": 1,
    "babel/semi": 1,
    "babel/no-unused-expressions": 1,
    "babel/valid-typeof": 1
  }
}

You can install JavaScript and TypeScript Nightly, then reopen VSCode.