Files
vscode/build/monaco
Remco Haszing c2f435a9bb Fix global access of MonacoEnvironment (#248075)
Fix global access of MonacoEnvironment

There are 3 ways to declare global variables in TypeScript.

1. A global `declare let`.
2. A global `declare var`.
3. Augmenting the global `Window`.

There are 4 ways to access global variables in the browser.

1. Using a global identifier.
2. Using the `globalThis` object.
3. Using the `window` object.
4. Using the `self` object.

Not all 3 types of global declarations work for all methods to access a
global.

|              | `let` | `var` | `Window` |
| ------------ | ----- | ----- | -------- |
| global       |   ✓   |   ✓   |          |
| `globalThis` |       |   ✓   |          |
| `window`     |       |   ✓   |    ✓     |
| `self`       |       |   ✓   |    ✓     |

So the proper way to declare the global `MonacoEnvironment`, is:

```ts
declare global var MonacoEnvironment: Environment | undefined
```

https://www.typescriptlang.org/play/?#code/PQgEB4CcFMDNpgOwMbVAGwJYCMC8AiAEwHsBbfUYAPgFgAoew6ZdAQxlAHN1jtX1QAb3qhRGaABdQAGUkAuUAGcJkTIk4ixAN3agAauwXLV6+ptFqJCWK1SgA6mpIB3IebGjHiIyrUa6HgC+9MEMdGDcvPygtqiKivSyEvQGkPReZuHAoM5OxK6ckvS5iC4AdEnFec5lqVWl+WUZYWAlLkpFdG2NSaC4oADkA-XlqX2Dw13VTWrjQ5kRPHzoACoAFpiKXJ2Ry+ubFTtL-PuKtez0uycbZ830i1GrNx3JdFdPB73982-HH2djb6Td6nGaIOaTe7ZRTQdCwbavGFww6I2Gwc5pOhI9F3LIdOEvejYlEQolojGkrHkryU+jQAAeAAdiJApIJAkA

---------

Co-authored-by: Henning Dieterichs <hdieterichs@microsoft.com>
2025-08-04 13:23:01 +00:00
..

Steps to publish a new version of monaco-editor-core

Generate monaco.d.ts

  • The monaco.d.ts is now automatically generated when running gulp watch

Bump version

  • increase version in build/monaco/package.json

Generate npm contents for monaco-editor-core

  • Be sure to have all changes committed and pushed to the remote
  • (the generated files contain the HEAD sha and that should be available on the remote)
  • run gulp editor-distro

Publish

  • cd out-monaco-editor-core
  • npm publish