@@ -17,8 +17,11 @@ const colors = {
17
17
darkgrey : "6D7891" ,
18
18
} ;
19
19
20
+ /** @type {HTMLIFrameElement | null | undefined } */
20
21
let iframeContainerElement ;
22
+ /** @type {HTMLDivElement | null | undefined } */
21
23
let containerElement ;
24
+ /** @type {Array<(element: HTMLDivElement) => void> } */
22
25
let onLoadQueue = [ ] ;
23
26
24
27
ansiHTML . setColors ( colors ) ;
@@ -38,7 +41,11 @@ function createContainer() {
38
41
iframeContainerElement . style . zIndex = 9999999999 ;
39
42
iframeContainerElement . onload = ( ) => {
40
43
containerElement =
41
- iframeContainerElement . contentDocument . createElement ( "div" ) ;
44
+ /** @type {Document } */
45
+ (
46
+ /** @type {HTMLIFrameElement } */
47
+ ( iframeContainerElement ) . contentDocument
48
+ ) . createElement ( "div" ) ;
42
49
containerElement . id = "webpack-dev-server-client-overlay-div" ;
43
50
containerElement . style . position = "fixed" ;
44
51
containerElement . style . boxSizing = "border-box" ;
@@ -71,6 +78,7 @@ function createContainer() {
71
78
closeButtonElement . style . color = "white" ;
72
79
closeButtonElement . style . cursor = "pointer" ;
73
80
closeButtonElement . style . cssFloat = "right" ;
81
+ // @ts -ignore
74
82
closeButtonElement . style . styleFloat = "right" ;
75
83
closeButtonElement . addEventListener ( "click" , ( ) => {
76
84
hide ( ) ;
@@ -81,19 +89,27 @@ function createContainer() {
81
89
containerElement . appendChild ( document . createElement ( "br" ) ) ;
82
90
containerElement . appendChild ( document . createElement ( "br" ) ) ;
83
91
84
- iframeContainerElement . contentDocument . body . appendChild ( containerElement ) ;
92
+ /** @type {Document } */
93
+ (
94
+ /** @type {HTMLIFrameElement } */
95
+ ( iframeContainerElement ) . contentDocument
96
+ ) . body . appendChild ( containerElement ) ;
85
97
86
98
onLoadQueue . forEach ( ( onLoad ) => {
87
- onLoad ( containerElement ) ;
99
+ onLoad ( /** @type { HTMLDivElement } */ ( containerElement ) ) ;
88
100
} ) ;
89
101
onLoadQueue = [ ] ;
90
102
91
- iframeContainerElement . onload = null ;
103
+ /** @type {HTMLIFrameElement } */
104
+ ( iframeContainerElement ) . onload = null ;
92
105
} ;
93
106
94
107
document . body . appendChild ( iframeContainerElement ) ;
95
108
}
96
109
110
+ /**
111
+ * @param {(element: HTMLDivElement) => void } callback
112
+ */
97
113
function ensureOverlayExists ( callback ) {
98
114
if ( containerElement ) {
99
115
// Everything is ready, call the callback right away.
@@ -124,6 +140,11 @@ function hide() {
124
140
containerElement = null ;
125
141
}
126
142
143
+ /**
144
+ * @param {string } type
145
+ * @param {string | { file?: string, moduleName?: string, loc?: string, message?: string } } item
146
+ * @returns {{ header: string, body: string } }
147
+ */
127
148
function formatProblem ( type , item ) {
128
149
let header = type === "warning" ? "WARNING" : "ERROR" ;
129
150
let body = "" ;
@@ -154,6 +175,10 @@ function formatProblem(type, item) {
154
175
}
155
176
156
177
// Compilation with errors (e.g. syntax error or missing modules).
178
+ /**
179
+ * @param {string } type
180
+ * @param {Array<string | { file?: string, moduleName?: string, loc?: string, message?: string }> } messages
181
+ */
157
182
function show ( type , messages ) {
158
183
ensureOverlayExists ( ( ) => {
159
184
messages . forEach ( ( message ) => {
@@ -177,7 +202,8 @@ function show(type, messages) {
177
202
entryElement . appendChild ( document . createElement ( "br" ) ) ;
178
203
entryElement . appendChild ( document . createElement ( "br" ) ) ;
179
204
180
- containerElement . appendChild ( entryElement ) ;
205
+ /** @type {HTMLDivElement } */
206
+ ( containerElement ) . appendChild ( entryElement ) ;
181
207
} ) ;
182
208
} ) ;
183
209
}
0 commit comments