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
Situation
There are lots of demand of more flexibility to Mapped Type. For example:
Extend from a type and override some fields
Turn optional field to required
Only make some specific fields to optional
Suggestion
Support multiple field definition in one type, the latter definition (same fields) will overwrite the previous
Support identifier! for type definition which will remove null and undefined.
Code
typeFull={field1: string;field2: string;
....fieldN: string;}//Suggestion 1: Multiple fields in type definition and support overridetypeSomeOptional={[PinkeyofFull]: Full[P];// extends[Pin'field1'|'field2']? : Full[P];// override field1 and field2 to optionalxxx: string;// and can add more fields.}//Suggestion 2: Identifer! to remove null and undefinedtypeSomeRequired={[PinkeyofSomeOptional]: SomeOptional[P];// extendsfield1: SomeOptional[field1]!;// ! will remove null and undefined from a type}