I’m trying to allow users to enter something like the following into a monaco editor instance (in react – @monaco-editor/react
):
{a: 1, b: 3 + 2}
Monaco syntax highlighting considers this a syntax error, because it would be one in a standalone js file (the curly braces would be interpreted as block curly braces).
As a workaround, users can enter the following, but it is unintuitive/annoying to need to:
({a: 1, b: 3 + 2})
Is there some way I can modify the monaco editor syntax highlighting to ignore this case or add parens in the background to convey it should be considered valid?