Reputation: 2554
I cant declare function, that returns promise to Derivable. Reason is next:
interface Some {
then(callback);
}
// Error: the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
async function foo(): Promise<Some> {
return null;
}
Is it bug in typescript? Is any workaround awailable? I cant use async/await because of this.
Upvotes: 0
Views: 2221
Reputation: 664246
No, this is not a bug in Typescript. It's just fundamentally impossible to fulfill a promise with a thenable (an object with a then
method), as it tries to assimilate it when resolving. As a workaround, you can wrap the Derivable
in an extra object, as a proper solution I would recommend renaming then
to chain
.
Upvotes: 5
Reputation: 1181
I think the problem is that typescript cannot recognize the different signature of the method then
because you kinda overrided it in the interface.
Upvotes: 0