-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add typescript typings #13
Comments
any news? ) |
Unfortunately not, but we are open to pull-requests if anyone is willing to help! |
The following piece in the declare module 'react-sizes' {
export interface Sizes {
width: number | false;
height: number | false;
}
type mapSizesToProps<SP extends object> = (sizes: Sizes) => SP;
export function withSizes<SP extends object, P extends SP>(
mapSizesToProps: mapSizesToProps<SP>,
): (component: React.ComponentType<P>) => React.ComponentType<P>;
export default withSizes;
} Note: This way, the output component expects the same props as the input component. Since withSizes already sets some props, this might raise issues with mandatory props. Therefore, you could e.g. use the |
thanks for contributing these types @janKir! I just created a PR to DefinitelyTyped with the types from your comment DefinitelyTyped/DefinitelyTyped#36058 the only modification that I made as to remove the |
meant to post this here earlier, but my PR made it into DefinitelyTyped 🎉 you can see the types for you can use the types in your TypeScript project with this command: yarn add -D @types/react-sizes |
The output component after the HOC has been applied should not support the same props that are injected by it. Even if it did support them, they would be overwritten by the HOC. More details on this can be found in the original draft for these types: renatorib/react-sizes#13 (comment)
No description provided.
The text was updated successfully, but these errors were encountered: