In my .js
files, when I use an elvis operator const something = data?.info?.set
, the entire file turns red after the line used.
How can I make VSCode recognize elvis operators and maintain syntax proper highlighting?
Note: I use metro-react-native-babel-preset
and eslint, which by default allows for optionals in pure .js files (not typescript)
I have installed https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-next and also followed the instructions to enable it. However, my code is still pure red color starting the line after I use the ?
operator.
Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names.
The easiest way to reset VS Code back to the default settings is to clear your user settings.json file. You can open the settings.json file with the Preferences: Open Settings (JSON) command in the Command Palette (Ctrl+Shift+P).
VS Code 1.41 supports syntax highlighting and IntelliSense for optional chaining (?.
) out of the box.
If you still see red highlighting with VS Code 1.41, either:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With