Skip to content
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

Emit declarations for function overloads #255

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

ianobermiller
Copy link
Contributor

@ianobermiller ianobermiller commented Oct 20, 2023

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

  • npm run compile
  • verify that lib/usePagination.d.ts has a usePagination definition that accepts null/undefined for the fragmentRef

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

Practically speaking, usePagination does not allow `null` in TypeScript with the current release because that definition is not emitted.
@morrys
Copy link
Member

morrys commented Oct 20, 2023

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
Copy link
Contributor Author

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 morrys merged commit c01226f into relay-tools:master Nov 6, 2023
1 check passed
@morrys
Copy link
Member

morrys commented Nov 7, 2023

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

@ianobermiller
Copy link
Contributor Author

Yay, thank you!

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

Successfully merging this pull request may close these issues.

2 participants