Skip to content

Instantly share code, notes, and snippets.

@holgergp
Last active January 14, 2022 10:21
Show Gist options
  • Save holgergp/cdb1fd51c39370063144ad90b8377425 to your computer and use it in GitHub Desktop.
Save holgergp/cdb1fd51c39370063144ad90b8377425 to your computer and use it in GitHub Desktop.
Tryout Awaited (TypeScript 4.5 Article)
let a: Promise<string>;
let b: Promise<Promise<string>>;
let c: Promise<Promise<Promise<string>>>
let d: Awaited<typeof c>
a===b
// error always returns false
// This condition will always return 'false' since the types 'Promise<Promise<string>>' and 'Promise<Promise<Promise<string>>>' have no overlap.ts(2367)
b===c
// error always returns false
const awaitA = await a
const awaitB = await b
const awaitC = await c
await a === await b
await a === await d
a===b
// error always returns false
// This condition will always return 'false' since the types 'Promise<Promise<string>>' and 'Promise<Promise<Promise<string>>>' have no overlap.ts(2367)
b===c
// error always returns false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment