Created
October 3, 2020 20:25
Accidental PromiseLike
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface PrintAdverb<T> { | |
then: <TResult1>(o: ((value: T) => PrintAdverb<TResult1>)) => PrintAdverb<TResult1>; | |
absolutely?: string; | |
positively?: string; | |
veryvery?: string; | |
necessary?: string; | |
} | |
const pa: PrintAdverb<string> = { | |
then: <TResult1>(o: ((value: string) => PrintAdverb<TResult1>)) => o('3') | |
} | |
Promise.resolve(pa) | |
.then( | |
// printer is a string because `Promise` | |
// thought it was a `PromiseLike` and | |
// 'unwrapped' it by calling then | |
(printer: string) => { | |
console.log('log flume'); | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment