unsplash / pipe-ts

34 stars 4 forks source link

Unexpected `unknown` when used with React components and other generic function types #3

Closed OliverJAsh closed 5 years ago

OliverJAsh commented 5 years ago

Filed a TS bug: https://github.com/microsoft/TypeScript/issues/32269

type ComponentType<P> = {
    (p: P): null;
    p?: P;
};

declare const myHoc: <Props>(
    ComposedComponent: ComponentType<Props>,
) => ComponentType<Props>;

declare const Component: (props: {}) => null;

// unknown, expected ComponentType<{}>
const result = pipe(
    () => Component,
    myHoc,
)();