1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/utils/defineGlobal.ts
Panu Horsmalahti 77c8617b79
Add confirmation dialog to extension uninstall (#1547)
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
2020-11-27 12:52:34 +02:00

14 lines
426 B
TypeScript
Executable File

// Setup variable in global scope (top-level object)
// Global type definition must be added separately to `mocks.d.ts` in form:
// declare const __globalName: any;
export function defineGlobal(propName: string, descriptor: PropertyDescriptor) {
const scope = typeof global !== "undefined" ? global : window;
if (scope.hasOwnProperty(propName)) {
return;
}
Object.defineProperty(scope, propName, descriptor);
}