Skip to content

Commit 0ed5ae6

Browse files
committed
refactor the createLocation to reduce conflicts
1 parent 6697c5e commit 0ed5ae6

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/global.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export {};
2+
3+
declare global {
4+
var window: {
5+
location?: {
6+
pathname?: string;
7+
};
8+
[key: string]: unknown;
9+
};
10+
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
export const createLocation = () => {
2-
// @ts-expect-error: allow non-read
3-
window.location = window.location || {
4-
pathname: 'default',
5-
};
2+
if (!global.window) {
3+
global.window = {};
4+
}
5+
6+
if (!global.window.location) {
7+
global.window.location = {
8+
pathname: 'default',
9+
};
10+
}
611
};

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"target": "ESNext",
44
"module": "ESNext",
5-
"lib": ["ESNext", "DOM"],
5+
"lib": ["ESNext"],
66
"moduleResolution": "Node",
77
"useDefineForClassFields": false,
88
"declaration": false,

0 commit comments

Comments
 (0)