-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix TS type declarations for BasemapName and CartoSlice #248
Conversation
Pull Request Test Coverage Report for Build 1591994246
💛 - Coveralls |
Code looks good to me, but we should check against Builder, linked locally, before we merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juandjara great job! 🚀
@VictorVelarde it's ready to check agains builder. |
@Clebal @VictorVelarde thanks for the quick response! |
Hello team! I've found some Typescript errors when setting up a new project from the template with Carto3 and Typescript and I saw a very easy correction of them so I created this PR. Let me know if you need any more context, tests, docs or anything like that
There are two changes in this PR:
changing the type of the
createCartoSlice
function. Instead of using the customReducer
type from thetypes.ts
file of the C4R library, we are importing theReducer
type fromredux
. This is a generic type, and as such, it should be defined asReducer<any, AnyAction>
. The VS Code tooltips let me know about this when I saw that the types for adding the cartoSlice to the store in the TS-template were not matching the redux types.changing the type of
BasemapName
from using&
to using|
. The&
operator in Typescript creates an intersection between types that does not work for joining two enum types together. I learned about that here when I was debugging why VS Code was again complaining in the basemap references scattered across the template. After much research, try, and error, I discovered that you just need to change the&
for an|
to mean "This type represents values from this enum OR this other enum"Edit:
Following @Clebal comment and the redux-typescript documentation I've changed the
cartoSlice
type to further indicate the types of the reducer usingReducer<CartoState, AnyAction>