mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
fix(overlay): minor ts fixes
This commit is contained in:
@ -45,7 +45,7 @@ export class LoadingController implements OverlayController {
|
|||||||
* Get the most recently opened loading overlay.
|
* Get the most recently opened loading overlay.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
getTop() {
|
getTop(): HTMLIonLoadingElement {
|
||||||
return getTopOverlay(this.loadings);
|
return getTopOverlay(this.loadings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ export class ModalController implements OverlayController {
|
|||||||
* Get the most recently opened modal overlay.
|
* Get the most recently opened modal overlay.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
getTop() {
|
getTop(): HTMLIonModalElement {
|
||||||
return getTopOverlay(this.modals);
|
return getTopOverlay(this.modals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
let lastId = 1;
|
let lastId = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make all properties in T readonly
|
* Convert an interface where all the properties are optional to mandatory.
|
||||||
*/
|
*/
|
||||||
export type PropDescriptions<K extends string> = {
|
export type Requires<K extends string> = {
|
||||||
[P in K]: any;
|
[P in K]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createOverlay
|
||||||
export function createOverlay<T extends HTMLIonOverlayElement & PropDescriptions<keyof B>, B>
|
<T extends HTMLIonOverlayElement & Requires<keyof B>, B>
|
||||||
(tagName: string, opts: B): Promise<T> {
|
(tagName: string, opts: B): Promise<T> {
|
||||||
// create ionic's wrapping ion-alert component
|
// create ionic's wrapping ion-alert component
|
||||||
const element = document.createElement(tagName) as T;
|
const element = document.createElement(tagName) as T;
|
||||||
@ -52,7 +52,7 @@ export function getHighestId(overlays: OverlayMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function removeLastOverlay(overlays: OverlayMap) {
|
export function removeLastOverlay(overlays: OverlayMap) {
|
||||||
const toRemove = getTopOverlay(overlays) as any;
|
const toRemove = getTopOverlay(overlays);
|
||||||
return toRemove ? toRemove.dismiss() : Promise.resolve();
|
return toRemove ? toRemove.dismiss() : Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user