@@ -8,10 +8,14 @@ import type {
8
8
MockWindow ,
9
9
} from '@stencil/core/mock-doc' ;
10
10
11
- type MockStorage = ReturnType < typeof mockWindow > [ 'localStorage' ] ;
12
- type MockEvent = ReturnType < typeof mockWindow > [ 'Event' ] ;
13
- type MockTimeout = ReturnType < typeof mockWindow > [ 'setTimeout' ] ;
14
- type MockSetInterval = ReturnType < typeof mockWindow > [ 'setInterval' ] ;
11
+ interface MockStorage {
12
+ localStorage : Storage ;
13
+ sessionStorage : Storage ;
14
+ }
15
+
16
+ interface MockEvent {
17
+ Event : Event ;
18
+ }
15
19
16
20
/**
17
21
* Extended global object that includes both Node.js globals and DOM APIs
@@ -68,16 +72,16 @@ export class StencilEnvironment {
68
72
this . global . document = win . document as unknown as MockDocument ;
69
73
this . global . HTMLElement = win . HTMLElement ;
70
74
this . global . customElements = win . customElements ;
71
- this . global . Event = win . Event ;
75
+ this . global . Event = win . Event as unknown as MockEvent ;
72
76
this . global . CustomEvent = win . CustomEvent ;
73
77
this . global . MouseEvent = win . MouseEvent ;
74
78
this . global . KeyboardEvent = win . KeyboardEvent ;
75
79
this . global . addEventListener = win . addEventListener . bind ( win ) as any ;
76
80
this . global . removeEventListener = win . removeEventListener . bind ( win ) ;
77
81
this . global . requestAnimationFrame = win . requestAnimationFrame . bind ( win ) ;
78
82
this . global . cancelAnimationFrame = win . cancelAnimationFrame . bind ( win ) ;
79
- this . global . localStorage = win . localStorage ;
80
- this . global . sessionStorage = win . sessionStorage ;
83
+ this . global . localStorage = win . localStorage as unknown as MockStorage ;
84
+ this . global . sessionStorage = win . sessionStorage as unknown as MockStorage ;
81
85
this . global . location = win . location ;
82
86
this . global . history = win . history ;
83
87
this . global . navigator = win . navigator ;
@@ -87,9 +91,9 @@ export class StencilEnvironment {
87
91
this . global . console = console ;
88
92
89
93
// Set up timing functions
90
- this . global . setTimeout = win . setTimeout . bind ( win ) as MockTimeout ;
94
+ this . global . setTimeout = win . setTimeout . bind ( win ) as unknown as typeof setTimeout ;
91
95
this . global . clearTimeout = win . clearTimeout . bind ( win ) ;
92
- this . global . setInterval = win . setInterval . bind ( win ) as MockSetInterval ;
96
+ this . global . setInterval = win . setInterval . bind ( win ) as unknown as typeof setInterval ;
93
97
this . global . clearInterval = win . clearInterval . bind ( win ) ;
94
98
95
99
// Set up URL
0 commit comments