1
사용자가 탭을 변경할 때 확인 대화 상자를 구성하고 있습니다. 코드는 제대로 작동하지만 tslint은 형식이 일치하지 않는다고 불평합니다.'IPromise <any>'을 'Promise <any>'에 할당 할 수 없습니다.
export class MyController implements ng.IController {
constructor(private $transitions: TransitionService,
private $translate: angular.translate.ITranslateService) {
'ngInject';
$transitions.onStart({},() =>
this.alert
.showConfirm(
this.$translate.instant('dialogs.confirmLeave.content'),
this.$translate.instant('dialogs.confirmLeave.title')
)
.then(() => true)
.catch(() => false)
);
}
...
}
this.alert.showConfirm
결국 각-UI-부트 스트랩에서 this.$uibModal.open()
를 호출처럼 컨트롤러가 보인다. 다음과 같은 경고 메시지가 표시됩니다.
error TS2345: Argument of type '() => IPromise<boolean>' is not assignable to parameter of type 'TransitionHookFn'.
Type 'IPromise<boolean>' is not assignable to type 'boolean | void | TargetState | Promise<boolean | void | TargetState>'.
Type 'IPromise<boolean>' is not assignable to type 'Promise<boolean | void | TargetState>'.
Types of property 'then' are incompatible.
Type '{ <TResult>(successCallback: (promiseValue: boolean) => TResult | IPromise<TResult>, errorCallbac...' is not assignable to type '<TResult1 = boolean | void | TargetState, TResult2 = never>(onfulfilled?: (value: boolean | void ...'.
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
Types of property 'then' are incompatible.
Type '{ <TResult>(successCallback: (promiseValue: any) => TResult | IPromise<TResult>, errorCallback?: ...' is not assignable to type '<TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>...'.
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
해결 방법에 대한 아이디어가 있습니까?