When using string literals the $ sign will get highlighted in red. I’m unsure if this is a problem with monaco editor. But the highlighting is correct in VS Code.
The code highlighting is using basic ruleset, which is most probably different from the one you use in your VSCode. For this particular case, you could create a shader asset and write the shader related code in it, instead of having an inline string.
You could then add it to your code e.g.:
// from assets
material.chunks.opacityPS = this.app.assets.find('myShader.ps', 'shader').resource;
// or from script attributes
MyScript.attributes.add('opacityPS', { type: 'asset', assetType: 'shader' });
...
material.chunks.opacityPS = this.opacityPS.resource;
That workaround would work yes.
But it doesn’t solve the problem. Which is wrong syntax highlighting.