Reputation: 175
I'm using Promise to void callback hell.
But I met the typecast issue.
here is my method or function define:
findById(entityId: string): Promise<mongoose.Document> {
return this._model.findById(entityId).exec();
}
The typescript tips some error about:
[ts] Type 'Promise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. Type '(onFulFill: (result: Document) => void | U | Promise, onReject?: (err: any) => void | U | P...' is not assignable to type '{ (onfulfilled?: (value: Document) => TResult | PromiseLike, onrejected?: (reas...'. Type 'Promise' is not assignable to type 'Promise'. Property 'catch' is missing in type 'Promise'.
I want to know how to void this issue?
Upvotes: 1
Views: 3649
Reputation: 979
Check for different promise types being used. In my case, one file was importing es6-promise
while the other wasn't.
Upvotes: 0