@@ -18,8 +18,6 @@ const schema = require("./options.json");
1818/** @typedef  {import("webpack").Stats } Stats */ 
1919/** @typedef  {import("webpack").MultiStats } MultiStats */ 
2020/** @typedef  {import("os").NetworkInterfaceInfo } NetworkInterfaceInfo */ 
21- /** @typedef  {import("express").Request } Request */ 
22- /** @typedef  {import("express").Response } Response */ 
2321/** @typedef  {import("express").NextFunction } NextFunction */ 
2422/** @typedef  {import("express").RequestHandler } ExpressRequestHandler */ 
2523/** @typedef  {import("express").ErrorRequestHandler } ExpressErrorRequestHandler */ 
@@ -42,14 +40,19 @@ const schema = require("./options.json");
4240
4341/** @typedef  {import("https").ServerOptions & { spdy?: { plain?: boolean | undefined, ssl?: boolean | undefined, 'x-forwarded-for'?: string | undefined, protocol?: string | undefined, protocols?: string[] | undefined }} } ServerOptions */ 
4442
43+ /** @typedef  {import("express").Request } Request */ 
44+ /** @typedef  {import("express").Response } Response */ 
45+ 
4546/** 
46-  * @template  Request, Response 
47-  * @typedef  {import("webpack-dev-middleware").Options<IncomingMessage, ServerResponse> } DevMiddlewareOptions 
47+  * @template  {Request} T 
48+  * @template  {Response} U 
49+  * @typedef  {import("webpack-dev-middleware").Options<T, U> } DevMiddlewareOptions 
4850 */ 
4951
5052/** 
51-  * @template  Request, Response 
52-  * @typedef  {import("webpack-dev-middleware").Context<IncomingMessage, ServerResponse> } DevMiddlewareContext 
53+  * @template  {Request} T 
54+  * @template  {Response} U 
55+  * @typedef  {import("webpack-dev-middleware").Context<T, U> } DevMiddlewareContext 
5356 */ 
5457
5558/** 
@@ -1841,36 +1844,20 @@ class Server {
18411844    const  {  app,  middleware }  =  this ; 
18421845
18431846    /** @type  {import("express").Application } */ 
1844-     ( app ) . get ( 
1845-       "/__webpack_dev_server__/sockjs.bundle.js" , 
1846-       /** 
1847-        * @param  {Request } req 
1848-        * @param  {Response } res 
1849-        * @returns  {void } 
1850-        */ 
1851-       ( req ,  res )  =>  { 
1852-         res . setHeader ( "Content-Type" ,  "application/javascript" ) ; 
1847+     ( app ) . get ( "/__webpack_dev_server__/sockjs.bundle.js" ,  ( req ,  res )  =>  { 
1848+       res . setHeader ( "Content-Type" ,  "application/javascript" ) ; 
18531849
1854-          const  clientPath  =  path . join ( __dirname ,  ".." ,  "client" ) ; 
1850+       const  clientPath  =  path . join ( __dirname ,  ".." ,  "client" ) ; 
18551851
1856-         res . sendFile ( path . join ( clientPath ,  "modules/sockjs-client/index.js" ) ) ; 
1857-       } , 
1858-     ) ; 
1852+       res . sendFile ( path . join ( clientPath ,  "modules/sockjs-client/index.js" ) ) ; 
1853+     } ) ; 
18591854
18601855    /** @type  {import("express").Application } */ 
1861-     ( app ) . get ( 
1862-       "/webpack-dev-server/invalidate" , 
1863-       /** 
1864-        * @param  {Request } _req 
1865-        * @param  {Response } res 
1866-        * @returns  {void } 
1867-        */ 
1868-       ( _req ,  res )  =>  { 
1869-         this . invalidate ( ) ; 
1856+     ( app ) . get ( "/webpack-dev-server/invalidate" ,  ( _req ,  res )  =>  { 
1857+       this . invalidate ( ) ; 
18701858
1871-         res . end ( ) ; 
1872-       } , 
1873-     ) ; 
1859+       res . end ( ) ; 
1860+     } ) ; 
18741861
18751862    /** @type  {import("express").Application } */ 
18761863    ( app ) . get ( "/webpack-dev-server/open-editor" ,  ( req ,  res )  =>  { 
@@ -1886,74 +1873,65 @@ class Server {
18861873    } ) ; 
18871874
18881875    /** @type  {import("express").Application } */ 
1889-     ( app ) . get ( 
1890-       "/webpack-dev-server" , 
1891-       /** 
1892-        * @param  {Request } req 
1893-        * @param  {Response } res 
1894-        * @returns  {void } 
1895-        */ 
1896-       ( req ,  res )  =>  { 
1897-         /** @type  {import("webpack-dev-middleware").API<Request, Response> }*/ 
1898-         ( middleware ) . waitUntilValid ( ( stats )  =>  { 
1899-           res . setHeader ( "Content-Type" ,  "text/html" ) ; 
1900-           // HEAD requests should not return body content 
1901-           if  ( req . method  ===  "HEAD" )  { 
1902-             res . end ( ) ; 
1903-             return ; 
1904-           } 
1905-           res . write ( 
1906-             '<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>' , 
1907-           ) ; 
1876+     ( app ) . get ( "/webpack-dev-server" ,  ( req ,  res )  =>  { 
1877+       /** @type  {import("webpack-dev-middleware").API<Request, Response> }*/ 
1878+       ( middleware ) . waitUntilValid ( ( stats )  =>  { 
1879+         res . setHeader ( "Content-Type" ,  "text/html" ) ; 
1880+         // HEAD requests should not return body content 
1881+         if  ( req . method  ===  "HEAD" )  { 
1882+           res . end ( ) ; 
1883+           return ; 
1884+         } 
1885+         res . write ( 
1886+           '<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>' , 
1887+         ) ; 
19081888
1909-            const  statsForPrint  = 
1910-              typeof  ( /** @type  {MultiStats } */  ( stats ) . stats )  !==  "undefined" 
1911-                ? /** @type  {MultiStats } */  ( stats ) . toJson ( ) . children 
1912-                : [ /** @type  {Stats } */  ( stats ) . toJson ( ) ] ; 
1889+         const  statsForPrint  = 
1890+           typeof  ( /** @type  {MultiStats } */  ( stats ) . stats )  !==  "undefined" 
1891+             ? /** @type  {MultiStats } */  ( stats ) . toJson ( ) . children 
1892+             : [ /** @type  {Stats } */  ( stats ) . toJson ( ) ] ; 
19131893
1914-            res . write ( `<h1>Assets Report:</h1>` ) ; 
1894+         res . write ( `<h1>Assets Report:</h1>` ) ; 
19151895
1916-           /** 
1917-            * @type  {StatsCompilation[] } 
1918-            */ 
1919-           ( statsForPrint ) . forEach ( ( item ,  index )  =>  { 
1920-             res . write ( "<div>" ) ; 
1921- 
1922-             const  name  = 
1923-               // eslint-disable-next-line no-nested-ternary 
1924-               typeof  item . name  !==  "undefined" 
1925-                 ? item . name 
1926-                 : /** @type  {MultiStats } */  ( stats ) . stats 
1927-                   ? `unnamed[${ index }  ]` 
1928-                   : "unnamed" ; 
1929- 
1930-             res . write ( `<h2>Compilation: ${ name }  </h2>` ) ; 
1931-             res . write ( "<ul>" ) ; 
1932- 
1933-             const  publicPath  = 
1934-               item . publicPath  ===  "auto"  ? ""  : item . publicPath ; 
1935- 
1936-             for  ( const  asset  of  /** @type  {NonNullable<StatsCompilation["assets"]> } */  ( 
1937-               item . assets 
1938-             ) )  { 
1939-               const  assetName  =  asset . name ; 
1940-               const  assetURL  =  `${ publicPath } ${ assetName }  ` ; 
1941- 
1942-               res . write ( 
1943-                 `<li> 
1896+         /** 
1897+          * @type  {StatsCompilation[] } 
1898+          */ 
1899+         ( statsForPrint ) . forEach ( ( item ,  index )  =>  { 
1900+           res . write ( "<div>" ) ; 
1901+ 
1902+           const  name  = 
1903+             // eslint-disable-next-line no-nested-ternary 
1904+             typeof  item . name  !==  "undefined" 
1905+               ? item . name 
1906+               : /** @type  {MultiStats } */  ( stats ) . stats 
1907+                 ? `unnamed[${ index }  ]` 
1908+                 : "unnamed" ; 
1909+ 
1910+           res . write ( `<h2>Compilation: ${ name }  </h2>` ) ; 
1911+           res . write ( "<ul>" ) ; 
1912+ 
1913+           const  publicPath  =  item . publicPath  ===  "auto"  ? ""  : item . publicPath ; 
1914+ 
1915+           for  ( const  asset  of  /** @type  {NonNullable<StatsCompilation["assets"]> } */  ( 
1916+             item . assets 
1917+           ) )  { 
1918+             const  assetName  =  asset . name ; 
1919+             const  assetURL  =  `${ publicPath } ${ assetName }  ` ; 
1920+ 
1921+             res . write ( 
1922+               `<li> 
19441923              <strong><a href="${ assetURL }  " target="_blank">${ assetName }  </a></strong> 
19451924            </li>` , 
1946-               ) ; 
1947-             } 
1948- 
1949-             res . write ( "</ul>" ) ; 
1950-             res . write ( "</div>" ) ; 
1951-           } ) ; 
1925+             ) ; 
1926+           } 
19521927
1953-           res . end ( "</body></html>" ) ; 
1928+           res . write ( "</ul>" ) ; 
1929+           res . write ( "</div>" ) ; 
19541930        } ) ; 
1955-       } , 
1956-     ) ; 
1931+ 
1932+         res . end ( "</body></html>" ) ; 
1933+       } ) ; 
1934+     } ) ; 
19571935  } 
19581936
19591937  /** 
0 commit comments