Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to remove certain errors from Monaco Editor?

I'm adding TypeScript support to my application Data-Forge Notebook.

Its a notebook-style application for JavaScript. When I use the 'await' keyword in a code cell Monaco flags it as an error as shown in this screenshot:

Error from Monaco Editor

When the code is executed or exported this whole chunk of code gets wrapped in an async function so when that happens there is no error.

I need to be able to customize Monaco to remove this error because it doesn't make sense in this context.

Is it possible to remove or modify errors like this when using the Monaco editor?

like image 639
Ashley Davis Avatar asked Nov 07 '22 19:11

Ashley Davis


1 Answers

This is a bit late, but I've found another solution. It's possible to suppress errors by error code the following way:

monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
  diagnosticCodesToIgnore: [1375]
});

Where 1375 is the error code for the "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. (1375)" error.

like image 160
Peti29 Avatar answered Dec 08 '22 13:12

Peti29