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

Possible to define globals? #2222

Closed
mrkurt opened this issue Apr 26, 2019 · 4 comments
Closed

Possible to define globals? #2222

mrkurt opened this issue Apr 26, 2019 · 4 comments

Comments

@mrkurt
Copy link
Contributor

mrkurt commented Apr 26, 2019

I'm using some external libraries that expect certain globals (related to #2108). Can I define new globals in my main somehow?

@kitsonk
Copy link
Contributor

kitsonk commented Apr 26, 2019

Either reference globalThis or window, or indirect eval to access the global scope. To define additional globals in TypeScript you have to utilise the global namespace to add the types, for example:

declare global {
  something: string;
}

@mrkurt
Copy link
Contributor Author

mrkurt commented Apr 27, 2019

Ah globalThis did it! Thanks.

@mrkurt mrkurt closed this as completed Apr 27, 2019
@ry
Copy link
Member

ry commented Apr 27, 2019

@mrkurt do you have a patch for exposing Request/Response? I spent a moment trying to to expose these but got hung up...

@mrkurt
Copy link
Contributor Author

mrkurt commented Apr 28, 2019

@ry I don't! I also looked for a bit, and realized there's more missing than I thought. I'm working on running the ones we use for fly.io to see how they are, it's possible they'd be good options to include in deno — although your FormData is better:

https://github.com/superfly/fly/blob/master/packages/v8env/src/body_mixin.ts
https://github.com/superfly/fly/blob/master/packages/v8env/src/request.ts
https://github.com/superfly/fly/blob/master/packages/v8env/src/response.ts

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

No branches or pull requests

3 participants