Commit c2f435a
Fix global access of MonacoEnvironment (microsoft#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>1 parent 3a63678 commit c2f435a
File tree
3 files changed
+6
-16
lines changed- build
- monaco
- src/vs
3 files changed
+6
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 119 | + | |
| 120 | + | |
125 | 121 | | |
126 | 122 | | |
127 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 6 | + | |
| 7 | + | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 6 | + | |
| 7 | + | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
0 commit comments