question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

window.MonacoEnvironment isn’t defined in types.

See original GitHub issue

monaco-editor version: 0.26.1 Browser: N/A OS: N/A Playground code that reproduces the issue: N/A

The following TypeScript code:

window.MonacoEnvironment = {};

Yields:

Property 'MonacoEnvironment' does not exist on type 'Window & typeof globalThis'.

window.MonacoEnvironment isn’t defined by the type definitions, only the global MonacoEnvironment is.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
remcohaszingcommented, Nov 12, 2021

The types that have been added in https://github.com/microsoft/vscode/pull/128949 are incorrect. Due to how the types are processed, the global Window interface isn’t augmented.

/cc @alexdima

1reaction
remcohaszingcommented, Jul 25, 2021

Another approach I’d personally like even better, is to get rid of the global MonacoEnvironment altogether and configure this using a function.

import { setMonacoEnvironment } from 'monaco-editor/esm/vs/editor/editor.api';
// Both imports should work
// import { setMonacoEnvironment } from 'monaco-editor';

setMonacoEnvironment({
  getWorker(workerId, label) {
    switch (label) {
      case 'css':
        return new CssWorker();
      case 'editorWorkerService':
        return new MonacoWorker();
      case 'json':
        return new JsonWorker();
      case 'yaml':
        return new YamlWorker();
      default:
        throw new Error(`Unknown label ${label}`);
    }
  },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you explicitly set a new property on `window` in ...
Create a file called global.d.ts , e.g., /src/@types/global.d.ts , and then define an interface like: interface Window { myLib: any }.
Read more >
monaco-yaml - npm Package Health Analysis - Snyk
YAML language plugin for the Monaco Editor. It provides the following features when editing YAML files: Code completion, based on JSON schemas or...
Read more >
May 2022 (version 1.68) - Visual Studio Code
Currently, Go to Definition jumps to the type definition file (the .d.ts file) that defines the types for the target function or symbol....
Read more >
PowerFX Plugins: Part 1 - Monaco Editor for PowerF...
So, with that, let's jump into part 1: how to build our own simple, lightweight PFX editing window... Design. To meet my stated...
Read more >
YAML plugin for the Monaco Editor
window.MonacoEnvironment = { getWorker(moduleId, label) { switch (label) { case ... Editor in your project, then configure monaco-yaml as described above.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found