You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeB={foo: string,};typeD={foo: string,bar: number};declarefunctionequals<T>(a: T,b: T): boolean;functionf(b: B,d: D|undefined){// Used to work, now infers `B` and fails.if(equals(b,d)){}}
declarefunctionisObject(value: unknown): value is Record<string,unknown>;functionf1(obj: {}){if(isObject(obj)){// Worked, obj is narrowed to Record<string, unknown>obj["stuff"]}}functionf2(obj: {}|undefined){if(isObject(obj)){// Doesn't work obj is not narrowed.obj["stuff"]}}
Inference Change Between Unions of
undefined
#49938
Lots of examples
Here's a minimal break.
Playground link
undefined
, try to find the common super type, and re-addundefined
.getFalsyFlagsOfTypes
is a recursive fetch of flags)Narrowing Changes Against Top-ish Types
#49988
The
isMap
type predicate now narrows values to aMap<...> | ReadonlyMap<...>
instead ofMap<...>
if that's what you already had.Introduced by Improve narrowing logic for
instanceof
, type predicate functions, and assertion functions #49625Start with this example.
But people depend on the old behavior.
This is now different
But
ReadonlyMap<...> | Map<...>
just provides all the same methods asReadonlyMap<...>
.The
isObject
case is worse.Previous behavior was weird! (see playground)
Now neither example works. (see playground)
Will need to think through these.
WeakRef
exampleT
is never witnessed, andWeakRef
is supposed to be a proxy aroundT
itself.The text was updated successfully, but these errors were encountered: