Skip to content
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

Support for global declarations #529

Open
Soremwar opened this issue Nov 13, 2020 · 0 comments
Open

Support for global declarations #529

Soremwar opened this issue Nov 13, 2020 · 0 comments
Labels
globals Issues related to acquiring symbols available globally request Feature request

Comments

@Soremwar
Copy link

Note: This demonstration is a corner case and should be avoided by developers when possible. However since it's supported by TypeScript and in lack of a better solution it should be considered a "feature".

types.ts

declare global {
  var x: number;
}

globalThis.x = 1;

export {};

mod.ts

import "./types.ts";

console.log(x); ///Outputs 1, there is no compilation error

TypeScript is ok with this, and since you are writing a property in globalThis on import, JavaScript is as well. However deno lint will mark x as undefined.

@kitsonk kitsonk added feature a new feature request Feature request and removed feature a new feature labels Mar 4, 2021
@bartlomieju bartlomieju added the globals Issues related to acquiring symbols available globally label Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
globals Issues related to acquiring symbols available globally request Feature request
Projects
None yet
Development

No branches or pull requests

3 participants