Created
October 3, 2020 20:25
-
-
Save anthonyjoeseph/72d2c7fe16dea7c39c2a5cb466dcade2 to your computer and use it in GitHub Desktop.
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