Skip to content

Typescript type issues with 4.0.0 #61

Open
@RobRendell

Description

@RobRendell

Thank you so much for this package - it's great!

Your changelog for 4.0.0 say "the sizes object can now be either null, or an object with numeric width and height properties (never null)", but the types defined in src/index.d.ts still declares a type where the width and height properties can be null.

I think it should be something like:

declare module 'react-resize-aware' {
    const useResizeAware: <T = {width: number; height: number}>(customReporter?: (target: HTMLIFrameElement | null) => null | T) => [JSX.Element, null | T]
    export default useResizeAware
}

(Your current definition also declares that T extends object, but I didn't keep that in my suggestion above, because by my reading, if someone defined a customReporter function that returned something not an object, e.g. just a number, the javascript hook would be fine with it.)

Also, I note that your package.json doesn't define a types field pointing at dist/index.d.ts, which means that compilers and IDEs might not pick up on your .d.ts file. It would be great if you could add that, too.

Thanks again!

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