UnwrapPartial: Add test case for non-Partial instantiation#1412
Conversation
fbb130e to
827be34
Compare
|
I think this change is wrong because the removed guard is what preserves the documented no-op behavior for non- Please add this regression test: type MixedRequiredAndOptional = {
required: string;
optional?: number;
};
expectType<MixedRequiredAndOptional>({} as UnwrapPartial<MixedRequiredAndOptional>);This fails with the simplified implementation, but passes with the previous guarded version. |
This reverts commit 827be34.
UnwrapPartialUnwrapPartial
|
Whoa, good catch. Thanks for staying vigilant. I think this is worth merging for the guard alone. |
Yeah, the check is necessary in type UnwrapRequired<RequiredObjectType> =
RequiredObjectType extends Required<infer ObjectType>
? ObjectType
: 'No Match';
type T1 = UnwrapRequired<{a?: number; b: string}>;
//=> 'No Match'
type T2 = UnwrapRequired<{a: number; b?: string}>;
//=> 'No Match'
type T3 = UnwrapRequired<{a?: number; b?: string}>;
//=> 'No Match' |
UnwrapPartialUnwrapPartial: Add test case for non-Partial instantiation
Context