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

Write typings for useMultiState #2

Closed
whizkydee opened this issue Feb 20, 2020 · 4 comments · Fixed by #5
Closed

Write typings for useMultiState #2

whizkydee opened this issue Feb 20, 2020 · 4 comments · Fixed by #5
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@whizkydee
Copy link
Owner

No description provided.

@whizkydee whizkydee added enhancement New feature or request good first issue Good for newcomers labels Feb 20, 2020
@Lagily
Copy link

Lagily commented Mar 4, 2020

would be great to have this - do you have any ideas on how to supply types for the returned setters? Because they are dynami 'set' + prop.name it can be quite the challenge I would imagine.

@whizkydee
Copy link
Owner Author

Yeah, it's pretty much done. Unfortunately, TypeScript doesn't have an API that lets you dynamically compose object property names. There's an open feature request for it since 2016: microsoft/TypeScript/issues/12754

@Lagily
Copy link

Lagily commented Mar 4, 2020

I see, I was thinking something like this might be good enough, at least all properties of the setters would be functions then:

export default function useMultiState<T>(initialState: T): [T, (newState: Partial<T>) => void, { [key: string]: Function }];

I'll send a PR if you want

@whizkydee
Copy link
Owner Author

Sure, go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants