@@ -17,8 +17,11 @@ const colors = {
1717 darkgrey : "6D7891" ,
1818} ;
1919
20+ /** @type {HTMLIFrameElement | null | undefined } */
2021let iframeContainerElement ;
22+ /** @type {HTMLDivElement | null | undefined } */
2123let containerElement ;
24+ /** @type {Array<(element: HTMLDivElement) => void> } */
2225let onLoadQueue = [ ] ;
2326
2427ansiHTML . setColors ( colors ) ;
@@ -38,7 +41,11 @@ function createContainer() {
3841 iframeContainerElement . style . zIndex = 9999999999 ;
3942 iframeContainerElement . onload = ( ) => {
4043 containerElement =
41- iframeContainerElement . contentDocument . createElement ( "div" ) ;
44+ /** @type {Document } */
45+ (
46+ /** @type {HTMLIFrameElement } */
47+ ( iframeContainerElement ) . contentDocument
48+ ) . createElement ( "div" ) ;
4249 containerElement . id = "webpack-dev-server-client-overlay-div" ;
4350 containerElement . style . position = "fixed" ;
4451 containerElement . style . boxSizing = "border-box" ;
@@ -71,6 +78,7 @@ function createContainer() {
7178 closeButtonElement . style . color = "white" ;
7279 closeButtonElement . style . cursor = "pointer" ;
7380 closeButtonElement . style . cssFloat = "right" ;
81+ // @ts -ignore
7482 closeButtonElement . style . styleFloat = "right" ;
7583 closeButtonElement . addEventListener ( "click" , ( ) => {
7684 hide ( ) ;
@@ -81,19 +89,27 @@ function createContainer() {
8189 containerElement . appendChild ( document . createElement ( "br" ) ) ;
8290 containerElement . appendChild ( document . createElement ( "br" ) ) ;
8391
84- iframeContainerElement . contentDocument . body . appendChild ( containerElement ) ;
92+ /** @type {Document } */
93+ (
94+ /** @type {HTMLIFrameElement } */
95+ ( iframeContainerElement ) . contentDocument
96+ ) . body . appendChild ( containerElement ) ;
8597
8698 onLoadQueue . forEach ( ( onLoad ) => {
87- onLoad ( containerElement ) ;
99+ onLoad ( /** @type { HTMLDivElement } */ ( containerElement ) ) ;
88100 } ) ;
89101 onLoadQueue = [ ] ;
90102
91- iframeContainerElement . onload = null ;
103+ /** @type {HTMLIFrameElement } */
104+ ( iframeContainerElement ) . onload = null ;
92105 } ;
93106
94107 document . body . appendChild ( iframeContainerElement ) ;
95108}
96109
110+ /**
111+ * @param {(element: HTMLDivElement) => void } callback
112+ */
97113function ensureOverlayExists ( callback ) {
98114 if ( containerElement ) {
99115 // Everything is ready, call the callback right away.
@@ -124,6 +140,11 @@ function hide() {
124140 containerElement = null ;
125141}
126142
143+ /**
144+ * @param {string } type
145+ * @param {string | { file?: string, moduleName?: string, loc?: string, message?: string } } item
146+ * @returns {{ header: string, body: string } }
147+ */
127148function formatProblem ( type , item ) {
128149 let header = type === "warning" ? "WARNING" : "ERROR" ;
129150 let body = "" ;
@@ -154,6 +175,10 @@ function formatProblem(type, item) {
154175}
155176
156177// 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+ */
157182function show ( type , messages ) {
158183 ensureOverlayExists ( ( ) => {
159184 messages . forEach ( ( message ) => {
@@ -177,7 +202,8 @@ function show(type, messages) {
177202 entryElement . appendChild ( document . createElement ( "br" ) ) ;
178203 entryElement . appendChild ( document . createElement ( "br" ) ) ;
179204
180- containerElement . appendChild ( entryElement ) ;
205+ /** @type {HTMLDivElement } */
206+ ( containerElement ) . appendChild ( entryElement ) ;
181207 } ) ;
182208 } ) ;
183209}
0 commit comments