andmar8
January 27, 2020, 12:18pm
1
I have a vague recollection from some time ago that the answer to my question is “no”, but…
Is there any way in ionic 4 to explicitly specify the type of a component returned from a create method? For example, on an ion-loading or ion-modal
when you do:
const loading = await this.loadingController.create({message: ‘Hellooo’,duration: 2000});
or:
const modal = await this.modalController.create({component: ModalPage});
Is there anyway at all to import the type (like you used to be able to do in ionic 3) and define it, so your code would look like this…
const loading:Loading = await this.loadingController.create({message: ‘Hellooo’,duration: 2000});
or:
const modal:Modal = await this.modalController.create({component: ModalPage});
I can see that the types “are” defined and exported here:
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
*/
@Component({
tag: 'ion-loading',
styleUrls: {
ios: 'loading.ios.scss',
md: 'loading.md.scss'
},
scoped: true
})
export class Loading implements ComponentInterface, OverlayInterface {
private durationTimeout: any;
presented = false;
mode = getIonMode(this);
@Element() el!: HTMLIonLoadingElement;
/** @internal */
@Prop() overlayIndex!: number;
and
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
*/
@Component({
tag: 'ion-modal',
styleUrls: {
ios: 'modal.ios.scss',
md: 'modal.md.scss'
},
scoped: true
})
export class Modal implements ComponentInterface, OverlayInterface {
private gesture?: Gesture;
// Reference to the user's provided modal content
private usersElement?: HTMLElement;
// Whether or not modal is being dismissed via gesture
private gestureAnimationDismissing = false;
presented = false;
animation?: Animation;
mode = getIonMode(this);
I just can’t find what import statement gets access to them??? Like I say, I have this distant memory that you’re not actually supposed to do this anymore for “some reason”.
Can anyone shed any light?
andmar8
January 29, 2020, 10:33am
2
bump
Somebody must know… surely?
andmar8
February 18, 2020, 2:29pm
3
The answer does appear to be “no” unless an interface has been explicitly written/exposed
…because?