-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed as not planned
Closed as not planned
Copy link
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
π Search Terms
partial record mapped type generic constraint
π Version & Regression Information
- This changed between versions 3.9.7 and 4.0.5
β― Playground Link
π» Code
type Works<T extends object, U extends { [K in keyof T]?: any }> = U;
type Fails<T extends object, U extends Partial<Record<keyof T, any>>> = U;
type AB = {a: string, b:string}
type B = {b: string}
// These both work and evaluate to the same type
type TestWorks1 = Works<AB, B>
type TestFails1 = Fails<AB, B>
// No errors
type TestWorks2<T extends AB> = Works<T, B>
// Error: Type 'B' does not satisfy the constraint 'Partial<Record<keyof T, any>>'.
type TestFails2<T extends AB> = Fails<T, B>π Actual behavior
WorksandFailsbehave differentlyTestFails2results in an error
π Expected behavior
WorksandFailsbehave the sameTestFails2does not result in an error
Additional information about the issue
@easrng narrowed down the divergence in behavior between the two types to this line in checker.ts (screenshot because the file is too big for github to display):

Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed