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
//// Example 1//constfn=<Paramsextends{}>(params: Pick<Params,Exclude<keyofParams,never>>,): Params=>// Unexpected error/* Type 'Pick<Params, Exclude<keyof Params, never>>' is not assignable to type 'Params'. */params;//// Example 2//import*asReactfrom'react';import{ComponentType,FunctionComponent}from'react';typeUser={name: string};typeUserProp={user: User};exportconstmyHoc=function<ComposedComponentPropsextendsUserProp>(ComposedComponent: ComponentType<ComposedComponentProps>,){// These two should be equivalent, but they're not?// Doesn't work:typeProps=Pick<ComposedComponentProps,Exclude<keyofComposedComponentProps,never>>;// Works:// type Props = ComposedComponentProps;constComponent: FunctionComponent<Props>=props=>(// Unexpected error/* Type 'PropsWithChildren<Pick<ComposedComponentProps, Exclude<keyof ComposedComponentProps, never>>>' is not assignable to type 'IntrinsicAttributes & ComposedComponentProps & { children?: ReactNode; }'. Type 'PropsWithChildren<Pick<ComposedComponentProps, Exclude<keyof ComposedComponentProps, never>>>' is not assignable to type 'ComposedComponentProps'. */<ComposedComponent{...props}/>);returnComponent;};
TypeScript Version: 3.2.1
Search Terms: generic pick exclude
Code