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

enhance: Infer returntype of useFetcher()'s functions #310

Merged
merged 1 commit into from Apr 1, 2020

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Apr 1, 2020

Motivation

Previously it was just 'any', which is often not very helpful.

Solution

We'll grab from the fetch function as that's the simplest approach and most accurate.

Open questions

@github-actions
Copy link
Contributor

github-actions bot commented Apr 1, 2020

Size Change: 0 B

Total Size: 30.7 kB

ℹ️ View Unchanged
Filename Size Change
packages/legacy/dist/index.cjs.js 433 B 0 B
packages/legacy/dist/index.umd.min.js 376 B 0 B
packages/normalizr/dist/normalizr.es.min.js 2.17 kB 0 B
packages/rest-hooks/dist/index.cjs.js 17 kB 0 B
packages/rest-hooks/dist/index.umd.min.js 7.17 kB 0 B
packages/test/dist/index.cjs.js 1.89 kB 0 B
packages/use-enhanced-reducer/dist/index.cjs.js 1.08 kB 0 B
packages/use-enhanced-reducer/dist/index.umd.min.js 593 B 0 B

compressed-size-action

Params extends Readonly<object>,
S extends Schema
>(fetchShape: ReadShape<S, Params>, params: Params | null) {
export default function useRetrieve<Shape extends ReadShape<any, any>>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter of Shape rather than a part gives us more information. this is used in useFetcher() which infers its return type

Copy link

@nickcherry nickcherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you!

@ntucker ntucker merged commit bb75c15 into master Apr 1, 2020
@ntucker ntucker deleted the useFetcher-return branch April 1, 2020 21:33
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.

None yet

2 participants