- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
The example below shows how one ought to be able to implement the opposite of the mapped type Partial<T>, which should removeundefined from the type of every single property in an interface.
TypeScript Version: 2.9.0-dev.201xxxxx
Search Terms:
exclude undefined mapped optional
Code
typeNeverUndefined<T>={[KinkeyofT]: Exclude<T[K],undefined>;}interfaceMyInterface{undef: undefinedoptionalString?: string;stringOrUndefined: string|undefined;definedString: string;}typeNeverUndefinedMyInterface=NeverUndefined<MyInterface>;Expected behavior:
// typeof NeverUndefinedMyInterfaceinterfaceNeverUndefinedMyInterface{undef: never;optionalString: string;stringOrUndefined: string;definedString: string;}Actual behavior:
// typeof NeverUndefinedMyInterfaceinterfaceNeverUndefinedMyInterface{undef: never;optionalString: string|undefined;stringOrUndefined: string;definedString: string;}(notice that optionalString still contains undefined in its type definition)
Related Issues:
None
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug