Skip to content

Instantly share code, notes, and snippets.

@anthonyjoeseph
Created October 3, 2020 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyjoeseph/72d2c7fe16dea7c39c2a5cb466dcade2 to your computer and use it in GitHub Desktop.
Save anthonyjoeseph/72d2c7fe16dea7c39c2a5cb466dcade2 to your computer and use it in GitHub Desktop.
Accidental PromiseLike
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