@@ -117,6 +117,7 @@ function getOrCreateSection(id, classes) {
117117 el = document . createElement ( "section" ) ;
118118 el . id = id ;
119119 el . className = classes ;
120+ // MAIN_ID exists, and is not the root
120121 // @ts -expect-error
121122 insertAfter ( el , document . getElementById ( MAIN_ID ) ) ;
122123 }
@@ -154,8 +155,7 @@ function switchDisplayedElement(elemToDisplay) {
154155 const el = getAlternativeDisplayElem ( ) ;
155156
156157 if ( el . children . length > 0 ) {
157- // @ts -expect-error
158- getNotDisplayedElem ( ) . appendChild ( el . firstElementChild ) ;
158+ getNotDisplayedElem ( ) . appendChild ( nonnull ( el . firstElementChild ) ) ;
159159 }
160160 if ( elemToDisplay === null ) {
161161 addClass ( el , "hidden" ) ;
@@ -202,7 +202,7 @@ function preLoadCss(cssUrl) {
202202 /**
203203 * Run a JavaScript file asynchronously.
204204 * @param {string } url
205- * @param {function(): any } errorCallback
205+ * @param {function(): any } [ errorCallback]
206206 */
207207 function loadScript ( url , errorCallback ) {
208208 const script = document . createElement ( "script" ) ;
@@ -224,7 +224,6 @@ function preLoadCss(cssUrl) {
224224 event . preventDefault ( ) ;
225225 // Sending request for the CSS and the JS files at the same time so it will
226226 // hopefully be loaded when the JS will generate the settings content.
227- // @ts -expect-error
228227 loadScript ( getVar ( "static-root-path" ) + getVar ( "settings-js" ) ) ;
229228 // Pre-load all theme CSS files, so that switching feels seamless.
230229 //
@@ -811,6 +810,7 @@ function preLoadCss(cssUrl) {
811810 }
812811 const implementors = implementorsElems ( "implementors-list" ) ;
813812 const syntheticImplementors = implementorsElems ( "synthetic-implementors-list" ) ;
813+ /** @type {Set<string> } */
814814 const inlined_types = new Set ( ) ;
815815
816816 const TEXT_IDX = 0 ;
@@ -829,17 +829,14 @@ function preLoadCss(cssUrl) {
829829 if ( ! aliases ) {
830830 return ;
831831 }
832- // @ts -expect-error
833- aliases . split ( "," ) . forEach ( alias => {
832+ aliases . split ( "," ) . forEach ( /** @param {string } alias */ alias => {
834833 inlined_types . add ( alias ) ;
835834 } ) ;
836835 } ) ;
837836 }
838837
839- // @ts -expect-error
840- let currentNbImpls = implementors [ 0 ] . getElementsByClassName ( "impl" ) . length ;
841- // @ts -expect-error
842- const traitName = document . querySelector ( ".main-heading h1 > .trait" ) . textContent ;
838+ let currentNbImpls = nonnull ( implementors [ 0 ] ) . getElementsByClassName ( "impl" ) . length ;
839+ const traitName = nonnull ( document . querySelector ( ".main-heading h1 > .trait" ) ) . textContent ;
843840 const baseIdName = "impl-" + traitName + "-" ;
844841 const libs = Object . getOwnPropertyNames ( imp ) ;
845842 // We don't want to include impls from this JS file, when the HTML already has them.
@@ -859,7 +856,8 @@ function preLoadCss(cssUrl) {
859856
860857 struct_loop:
861858 for ( const struct of structs ) {
862- const list = struct [ SYNTHETIC_IDX ] ? syntheticImplementors : implementors ;
859+ const [ impList , negImpMarker ] =
860+ struct [ SYNTHETIC_IDX ] ? syntheticImplementors : implementors ;
863861
864862 // The types list is only used for synthetic impls.
865863 // If this changes, `main.js` and `write_shared.rs` both need changed.
@@ -898,11 +896,9 @@ function preLoadCss(cssUrl) {
898896 // If this is a negative implementor, we put it into the right location (just
899897 // before the negative impl marker).
900898 if ( struct [ IS_NEG_IDX ] ) {
901- // @ts -expect-error
902- list [ 1 ] . before ( display ) ;
899+ nonnull ( negImpMarker ) . before ( display ) ;
903900 } else {
904- // @ts -expect-error
905- list [ 0 ] . appendChild ( display ) ;
901+ nonnull ( impList ) . appendChild ( display ) ;
906902 }
907903 currentNbImpls += 1 ;
908904 }
@@ -978,8 +974,7 @@ function preLoadCss(cssUrl) {
978974 const text = impList [ 0 ] ;
979975 const traitName = impList [ 1 ] ;
980976 const isTrait = typeof traitName === "string" ;
981- // @ts -expect-error
982- if ( types . indexOf ( selfPath ) === - 1 ) {
977+ if ( selfPath === null || types . indexOf ( selfPath ) === - 1 ) {
983978 continue ;
984979 }
985980 let outputList = isTrait ? trait_implementations : implementations ;
0 commit comments