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

compose hoc causes to lose typings #785

Open
sergeyzwezdin opened this issue Oct 22, 2019 · 0 comments
Open

compose hoc causes to lose typings #785

sergeyzwezdin opened this issue Oct 22, 2019 · 0 comments

Comments

@sergeyzwezdin
Copy link

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()?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant