relay-tools / relay-hooks

Use Relay as React hooks
https://relay-tools.github.io/relay-hooks/docs/relay-hooks.html
MIT License
542 stars 56 forks source link

Emit declarations for function overloads #255

Closed ianobermiller closed 1 year ago

ianobermiller commented 1 year ago

When you have an overloaded function the declaration doesn't emit type on the function body, so you have to duplicate it.

Practically speaking, usePagination does not allow null in TypeScript with the current release because that definition is not emitted.

While I was modifying these, I made them also accept undefined which you often get from Relay generated types. It is handled the same as null.

Test Plan

morrys commented 1 year ago

Hi @ianobermiller, I really didn't expect such behavior, thanks for the PR :)

As for the undefined, I tried to keep aligned with the typescript version of react-relay DefinitelyTyped/DefinitelyTyped/react-relay/relay-hooks/useFragment

Do you think there's a problem there too?

ianobermiller commented 1 year ago

I'm not entirely sure what you mean. Adding undefined to the types in this repo brings it in line with the DefinitelyTyped types as well, so that seems good.

morrys commented 1 year ago

Hi @ianobermiller, this PR was released with version 8.0.2 https://github.com/relay-tools/relay-hooks/releases/tag/v8.0.2

ianobermiller commented 1 year ago

Yay, thank you!