-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add TypeScript typings for TabsConfigsType. #18
Add TypeScript typings for TabsConfigsType. #18
Comments
thanks @nandorojo for this well documented issue and possible solution. please feel free to submit a pr, i'll make sure to release it as soon as possible 😇 |
You got it! Happy to help. Do you know when you might be releasing other presets for the animation? Awesome project! |
Submitted PR. |
Thanks mate, for the next preset, i am working on a new one by Cuberto, hopefully by this weekend |
@nandorojo could you please point your PR to this repository :) |
Done 🙃 |
* Add TypeScript typings for TabsConfigsType Close #18 * chore: updated TabsConfig Co-authored-by: Fernando Rojo <frojo@sas.upenn.edu>
Awesome library. I'm happy to make a PR for this, if you're open to publishing it.
Feature Request
The default tabs object looks like this:
The keys,
Home
andProfile
, could be any strings. I think this should be changed to be the keys of the tabs. This could be implemented by pulling the types passed to thecreateBottomTabNavigator
.Why it is needed
Prevent this error from happening, due to unclear types:
Possible implementation
In
src/types.ts
, this line defines the type for the dictionary:I think the goal should be to let you optionally pass your React Navigation
ParamList
type as an argument.For example, if your
Tab
looks like this:...then you should be able to pass
Params
as an argument toTabsConfigsType
.Proposed solution
Change this:
To this:
The first generic,
T = { [key: string]: TabConfigsType }
is optional, since it has a default value. That default value is equal to the current type. If you don't provide a param list argument, then it will fall back to this.The second generic,
K extends keyof T = keyof T
, extracts the keys. Say your param list is like this:Meanwhile, if you don't pass a generic, it will work normally:
I changed it to a
type
, because the TypeScriptinterface
doesn't support extracting a key from a union ([key in K]: TabConfigsType
isn't possible in aninterface
).Code sample
The text was updated successfully, but these errors were encountered: