-
Notifications
You must be signed in to change notification settings - Fork 430
Conversation
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.
minor comments on typescript stuffs
src/actions/app.ts
Outdated
@@ -48,27 +60,27 @@ const loadPage = (page) => (dispatch) => { | |||
dispatch(updatePage(page)); | |||
}; | |||
|
|||
const updatePage = (page) => { | |||
const updatePage: ActionCreator<Action> = (page: string) => { |
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.
How about using a more specific type:
const updatePage: ActionCreator<AppActionUpdatePage> = (page: string) => {
or
const updatePage = (page: string): AppActionUpdatePage => {
src/actions/app.ts
Outdated
opened | ||
}); | ||
} | ||
export const updateDrawerState: ActionCreator<Action> = (opened: boolean) => { |
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.
Use AppActionUpdateDrawerState
src/actions/counter.ts
Outdated
export interface CounterActionIncrement extends Action<'INCREMENT'> {}; | ||
export interface CounterActionDecrement extends Action<'DECREMENT'> {}; | ||
export type CounterAction = CounterActionIncrement | CounterActionDecrement; | ||
|
||
export const increment = () => { |
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.
Add type CounterActionIncrement
, e.g. export const increment = (): CounterActionIncrement => {
src/actions/shop.ts
Outdated
dispatch(addToCartUnsafe(productId)); | ||
} | ||
}; | ||
|
||
export const removeFromCart = (productId) => { | ||
export const removeFromCart: ActionCreator<Action> = (productId) => { |
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.
<Action>
-> <ShopActionRemoveFromCart>
src/actions/shop.ts
Outdated
return { | ||
type: REMOVE_FROM_CART, | ||
productId | ||
}; | ||
}; | ||
|
||
export const addToCartUnsafe = (productId) => { | ||
export const addToCartUnsafe: ActionCreator<Action> = (productId) => { |
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.
ShopActionAddToCart
Ignore the .d.ts, .js & .js.map just in src folder
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
So... this is meant to be turned into a "supported" template soon, right? |
It's mostly finished. Currently waiting on:
Haven't looked into the TS 3.1 issues - that's probably for another PR. The process of "releasing" this template will probably just be renaming this branch to |
About the underscore, you are also going to eliminate it from the properties? |
@abdonrd no - the convention is no underscore on protected methods |
By the way, any plan to add |
Also, any plan to setup some TSLint config? |
watch would be nice-to-have for |
Done at #244! |
TS 3.1 issue - blocked on release of Polymer/polymer#5370 (with updated legacy-element-mixin.d.ts) Update: I think we need this as well - Polymer/polymer#5371 |
@felipecesar42 I agree with that. That's what lit-html does by setting |
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.
Looks good!
Ack the number of files comment. Could consider moving TS source to a CLA ok |
export const UPDATE_PAGE = 'UPDATE_PAGE'; | ||
export const UPDATE_OFFLINE = 'UPDATE_OFFLINE'; | ||
export const UPDATE_DRAWER_STATE = 'UPDATE_DRAWER_STATE'; | ||
export const OPEN_SNACKBAR = 'OPEN_SNACKBAR'; | ||
export const CLOSE_SNACKBAR = 'CLOSE_SNACKBAR'; | ||
|
||
export const navigate = (path) => (dispatch) => { | ||
export interface AppActionUpdatePage extends Action<'UPDATE_PAGE'> {page: string}; |
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.
@keanulee why export these interfaces?
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.
Oh, I guess store.js only uses AppAction
, not these interfaces. No good reason, but maybe someone might want to create the action before dispatching it?
const action = actionCreator(param);
store.dispatch(action);
PR opened for review comments only - this branch serves as a template on how to use TypeScript.
Fixes #232