Closed
Description
#49625 breaks node's type tests on DT.
Note that this causes node's util
to return a union where it didn't before:
function isMap<T>(object: T | {}): object is T extends ReadonlyMap<any, any> ? (unknown extends T ? never : ReadonlyMap<any, any>) : Map<unknown, unknown>;
declare const romor: ReadonlyMap<any, any> | Record<any, any>
if (types.isMap(romor)) {
romor; // $ExpectType ReadonlyMap<any, any>
}
But it's ReadonlyMap<any, any> | Map<unknown, unknown>
now.
I think this is correct, because the conditional type distributes and ReadonlyMap extends ReadonlyMap, while Record<any, any> doesn't. So the result is the union of the conditional's branches. However, this might turn out to be too big a breaking change for node, so I want to track it here.
@peterblazejewicz also noticed discussion at DefinitelyTyped/DefinitelyTyped#61353 on this change.
Metadata
Metadata
Assignees
Labels
No labels