Open
Description
Bug Report
π Search Terms
Promise<any>
Promise<unknown>
instantiation order
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ
β― Playground Link
Playground link with relevant code
π» Code
// Reorder these two
declare let u: Promise<unknown>
declare let a: Promise<any>
// Assigned an expression that is Promise<any> | Promise<unknown>
// but that will undergo subtype reduction
// The type of union depends on whether a or u was declared first
let union = Math.random() > 0.5
? Promise.reject<any>()
: Promise.reject<unknown>();
union.then(v => v.toString());
π Actual behavior
Reordering the unrelated variables u
and a
will cause the type of union
to change between Promise<unknown>
and Promise<any>
(both in declarations and in the type of v
, although tooltips still show union
as Promise<any>
)
π Expected behavior
The type of union
should not be impacted