Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion keeper/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ typings/

# Distributive
compiled
*.d.ts
*.d.ts

# Except these
!/__types__/*.d.ts
1 change: 1 addition & 0 deletions keeper/__types__/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const global: any;
3 changes: 2 additions & 1 deletion keeper/src/keeper/keeper.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const nil = null;
const BOLD = 'font-weight: bold;';
const globalThis = Function('return this')() as Window & {
type GlobalThis = Window & {
Date: DateConstructor;
perfKeeper?: {
system: PerfKeeper;
};
};
const globalThis = typeof window === 'undefined' ? typeof global === 'undefined' ? this : global : window as GlobalThis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Во, я просто не донес, сделай также как тут:
https://gist.github.com/RubaXa/078395065c3aa0ffee557fe072a70c57#file-global-ts-L3-L8

const Date = globalThis.Date;

const dateNow = Date.now;
Expand Down
1 change: 1 addition & 0 deletions performance/__types__/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const global: any;
3 changes: 2 additions & 1 deletion performance/src/performance/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ export function polyfill<T extends object>(global: T) {
};
}

const globalThis = polyfill(new Function('return this'));
const globalObject = typeof window === 'undefined' ? typeof global === 'undefined' ? this : global : window;
const globalThis = polyfill(globalObject);

if (typeof self !== 'undefined' && (self as any) !== globalThis) {
polyfill(self);
Expand Down