@@ -4,6 +4,13 @@ import { add_init_fn } from "./init.js";
44// A page may load its own Bootstrap; prefer it over the bundled copy.
55const page_bootstrap = ( ) => window . bootstrap ?? bundled_bootstrap ;
66
7+ /**
8+ * Bootstrap declares getOrCreateInstance on the base class, which returns a
9+ * BaseComponent and so loses show().
10+ * @typedef {InstanceType<typeof bundled_bootstrap.Toast> } ToastWidget
11+ * @typedef {InstanceType<typeof bundled_bootstrap.Modal> } ModalWidget
12+ */
13+
714const nonce = /** @type {HTMLScriptElement } */ ( document . currentScript ) . nonce ;
815
916function sqlpage_card ( ) {
@@ -368,7 +375,7 @@ function open_toasts_for_hash(toasts) {
368375 if ( ! hash ) return ;
369376 for ( const toast of toasts ) {
370377 if ( normalize_hash ( toast . dataset . toastTrigger ) === hash ) {
371- Toast . getOrCreateInstance ( toast ) . show ( ) ;
378+ /** @type { ToastWidget } */ ( Toast . getOrCreateInstance ( toast ) ) . show ( ) ;
372379 }
373380 }
374381}
@@ -413,7 +420,9 @@ function sqlpage_toast() {
413420 }
414421
415422 toast . removeAttribute ( "data-pre-init" ) ;
416- const instance = Toast . getOrCreateInstance ( toast ) ;
423+ const instance = /** @type {ToastWidget } */ (
424+ Toast . getOrCreateInstance ( toast )
425+ ) ;
417426 initialized_toasts . push ( toast ) ;
418427 toast . addEventListener ( "hidden.bs.toast" , ( ) => {
419428 restore_focus_after_toast ( toast , container ) ;
@@ -488,7 +497,9 @@ function open_modal_for_hash() {
488497 if ( ! hash ) return ;
489498 const modal = document . getElementById ( hash ) ;
490499 if ( ! modal ?. classList . contains ( "modal" ) ) return ;
491- const bootstrap_modal = page_bootstrap ( ) . Modal . getOrCreateInstance ( modal ) ;
500+ const bootstrap_modal = /** @type {ModalWidget } */ (
501+ page_bootstrap ( ) . Modal . getOrCreateInstance ( modal )
502+ ) ;
492503 bootstrap_modal . show ( ) ;
493504 modal . addEventListener (
494505 "hidden.bs.modal" ,
0 commit comments