Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

compose hoc causes to lose typings #785

@sergeyzwezdin

Description

@sergeyzwezdin

We use recompose@0.30.0 and @types/recompose@0.30.7 with the latest React. I'm not sure why, but for some reason, compose() HOC causes to loose typings for React component.

To demonstrate it I've created following simple code:

import React, { Component, FunctionComponent } from 'react';

import { compose } from 'recompose';

type Component1Props = {
	test: string;
};

const Component1: FunctionComponent<Component1Props> = ({ test }) => <div>{test}</div>;

const enhance = compose<Component1Props, Component1Props>();

export { Component1 };
export default enhance(Component1);

Here is what typescript generates in result:

import { FunctionComponent } from 'react';
declare type Component1Props = {
    test: string;
};
declare const Component1: FunctionComponent<Component1Props>;
export { Component1 };
declare const _default;
export default _default;
//# sourceMappingURL=component1.d.ts.map

As you can see, Component1 without compose() generates types normally, but once we apply compose(), we're going to lose all types.

image

Could you please advise how to keep types for components when we use compose()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions