Last active
March 5, 2020 17:33
-
-
Save n8jadams/27183f479f2a2c3f766c384e7aa71bb9 to your computer and use it in GitHub Desktop.
In Typescript, use the global object in Node, or the window object in the browser
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
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
// Nodeland | |
interface ExtendedGlobal extends NodeJS.Global { | |
someGlobalKey: string | |
} | |
export const extendedGlobal: ExtendedGlobal = global as any | |
// Browserland | |
interface ExtendedWindow extends Window { | |
someWindowKey: string | |
} | |
export const extendedWindow: ExtendedWindow = window as any |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment