-
Notifications
You must be signed in to change notification settings - Fork 4
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
Flow error on flow version 113 #20
Comments
Oh, one more thing. Oddly, when I export the
Not sure if it's related. |
Adding // @flow
import { action, createActions, handleActions } from 'typed-actions';
const LOAD_THREAD_DATA = '@threads/LOAD_THREAD_DATA';
const actions = createActions<any>({
[LOAD_THREAD_DATA]: (threadId: string) => action({ threadId }),
});
type Actions = typeof actions;
export const loadThreadData = actions[LOAD_THREAD_DATA]; |
Also potentially related: https://medium.com/flow-type/asking-for-required-annotations-64d4f9c1edf8. Maybe it is no longer possible for this to be implicitly typed? |
Hi @TJTorola, thank you for the issue! And excuse me for delay please.
That's right! Although all the types are strictly defined, there are problems with types resolution from Just a simple example of the idea export type User = { name?: string, id: string, offers?: Offer[] };
export const user = createActions("@namespace/USER", {
get: (id: string) => action(id),
done: (user: User) => action(user),
});
user.done({ id: "1", name: "user" });
user.done({ name: "user" }); // expected error
export type Offer = { name: string, id: string, title: string };
export const offer = createActions("@namespace/OFFER", {
get: (id: string) => action({ id }),
done: (offer: Offer) => action(offer),
});
type State = { user: User };
const initialState = {}
export default handleActions<State>(initialState)(
[user, {
get: (state, { payload }) => ({ user: { id: payload } }),
done: (state, { payload }) => ({ user: payload }),
}],
[offer, {
done: ({ user }, { payload }) => ({
user: {
...user,
offers: [payload].concat(user.offers || []),
},
}),
}],
); |
@lttb No problem for the delay. That interface looks nice! A bit of a change since we couldn't do something like |
@lttb One followup thought on that pattern. In our particular app it is often useful to get the type of some specific action to be able to respond to it elsewhere, maybe in middleware or a different reducer. Would there be a way to pull that off with this new interface? |
I'm running into the following flow errors when running on version 113. Similar code on another repo with version 84 is passing just fine.
The code that I am adding that is triggering the issue is as follows:
I'll probably take a stab at seeing if I can correct the flowtypes (if that is actually the issue) but it's a bit over my head.
The text was updated successfully, but these errors were encountered: