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+