I searched a lot but couldn't find. My Codes as below.
I created one alertify Service but I get the following error: "Type 'undefined' cannot be used as an index type. Partial<Class> undefined ?"
I don't understand why the code is detecting my index type as 'undefined'.
import { Injectable } from '@angular/core';
declare let alertify: any;
@Injectable({
providedIn: 'root'
})
export class AlertifyService {
constructor() { }
message(message: string, options: Partial<AlertifyOptions>) {
alertify.set('notifier', 'position', options.position);
alertify.set('notifier', 'delay', options.delay);
alertify[options.messageType](message);
}
}
export class AlertifyOptions {
messageType: AlertifyMessageType = AlertifyMessageType.Success;
position: AlertifyPositions = AlertifyPositions.BottomRightCenter;
delay: number = 3;
dismissOthers: boolean = false;
}
export enum AlertifyMessageType {
Success = "success",
Warning = "warning",
Message = "message",
Error = "error",
Notifier = "notifier"
}
export enum AlertifyPositions {
TopRight = "top-right",
TopCenter = "top-center",
Topleft = "top-left",
BottomRight = "bottom-right",
BottomRightCenter = "bottom-center",
BottomRightBottom = "bottom-right"
}