Skip to content

Conversation

@remcohaszing
Copy link
Contributor

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:

declare global var MonacoEnvironment: Environment | undefined

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

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
@hediet
Copy link
Member

hediet commented May 15, 2025

CI still seems to be failing

@remcohaszing
Copy link
Contributor Author

I see the failed check on GitHub, but I’m not able to login to Azure to see the logs.

Sorry, but we’re having trouble signing you in. AADSTS50020: User account 'remcohaszing@gmail.com' from identity provider 'live.com' does not exist in tenant 'Microsoft' and cannot access the application '499b84ac-1321-427f-aa17-267ca6975798'(Azure DevOps) in that tenant. The account needs to be added as an external user in the tenant first. Sign out and sign in again with a different Azure Active Directory user account.

@hediet hediet added this to the June 2025 milestone Jun 3, 2025
@hediet hediet modified the milestones: June 2025, July 2025 Jul 1, 2025
@hediet hediet modified the milestones: July 2025, August 2025 Jul 27, 2025
@hediet hediet enabled auto-merge (squash) August 4, 2025 13:12
@hediet hediet merged commit c2f435a into microsoft:main Aug 4, 2025
17 checks passed
@remcohaszing remcohaszing deleted the fix-global-monaco-environment branch August 4, 2025 14:36
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants