Created
January 15, 2024 14:49
-
-
Save adrienjoly/e5b1b2f4b3b5f988eff2f155756841c9 to your computer and use it in GitHub Desktop.
Typing a `globalThis` variable on Node.js, using TypeScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare global { | |
// Note: It is crucial to note that [...] variables must only be declared using var | |
// cf https://copyprogramming.com/howto/using-globalthis-in-typescript | |
var myGlobalVariable: string; | |
} | |
// => `globalThis.myGlobalVariable` is properly typed as `string` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment