Skip to content

Fix global access of MonacoEnvironment #248075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants