diff --git a/src/modal/modal-ref.ts b/src/modal/modal-ref.ts index 094a05b6c7..2477d8ef11 100644 --- a/src/modal/modal-ref.ts +++ b/src/modal/modal-ref.ts @@ -30,7 +30,7 @@ export class NgbActiveModal { /** * A reference to the newly opened modal returned by the `NgbModal.open()` method. */ -export class NgbModalRef { +export class NgbModalRef { private _resolve: (result?: any) => void; private _reject: (reason?: any) => void; @@ -39,7 +39,7 @@ export class NgbModalRef { * * When a `TemplateRef` is used as the content or when the modal is closed, will return `undefined`. */ - get componentInstance(): any { + get componentInstance(): T extends new (...args: any[]) => any? InstanceType: undefined { if (this._contentRef && this._contentRef.componentRef) { return this._contentRef.componentRef.instance; } diff --git a/src/modal/modal.spec.ts b/src/modal/modal.spec.ts index 6db15a5722..bce49e5caa 100644 --- a/src/modal/modal.spec.ts +++ b/src/modal/modal.spec.ts @@ -1087,7 +1087,7 @@ export class WithSkipTabindexFirstFocusableModalCmpt { }) class TestComponent { name = 'World'; - openedModal: NgbModalRef; + openedModal: NgbModalRef; show = true; @ViewChild('content', {static: true}) tplContent; @ViewChild('destroyableContent', {static: true}) tplDestroyableContent; diff --git a/src/modal/modal.ts b/src/modal/modal.ts index 38e832d0a7..6f438b3cd9 100644 --- a/src/modal/modal.ts +++ b/src/modal/modal.ts @@ -25,7 +25,7 @@ export class NgbModal { * * Also see the [`NgbModalOptions`](#/components/modal/api#NgbModalOptions) for the list of supported options. */ - open(content: any, options: NgbModalOptions = {}): NgbModalRef { + open(content: T, options: NgbModalOptions = {}): NgbModalRef { const combinedOptions = Object.assign({}, this._config, options); return this._modalStack.open(this._moduleCFR, this._injector, content, combinedOptions); }