just want user is a data state not a modal
interface User {
name: string;
getDisplayName: () => string
}
interface UserModal {
user: User;
fetchUser: thunk(.....)
}
const user = useStoreState(state => state.userModal.user)
the user is StateMapper\
Hi @yongningfu 馃憢
I'm sorry to see you are frustrated. That being said can I please ask you avoid using things like "!!!!" in your communications. It comes off as an aggressive tone, and no-one needs that in their lives.
We will be happy to help, but could I ask that you create a minimal example on codesandbox.io. Here is a starter template to help even.
@ctrlplusb sorry abort that, i just write a example https://codesandbox.io/s/easy-peasytypescript-tutorialtyped-computed-entire-state-ld1zl
@ctrlplusb i use immutable.js with easy-peasy, i want to keep user is a immutable record model, not wrapper state with it
Hi @yongningfu
So to be clear you don't like that it is reporting state.user to be of type _Merge<StateMapper<_Pick<_Pick<User, "id" | "name" | "displayName" | "has" | "get" | "hasIn" | "getIn" | "equals" | "hashCode" | "set" | "update" | "merge" | "mergeDeep" | "mergeWith" | "mergeDeepWith" | ... 16 more ... | "toSeq">, "displayName" | ... 28 more ... | "toSeq">, "2">, _Pick<...>>?
Do the immutable API's still work even though the type is definition has changed to this?
Hi @yongningfu
So to be clear you don't like that it is reporting
state.userto be of type_Merge<StateMapper<_Pick<_Pick<User, "id" | "name" | "displayName" | "has" | "get" | "hasIn" | "getIn" | "equals" | "hashCode" | "set" | "update" | "merge" | "mergeDeep" | "mergeWith" | "mergeDeepWith" | ... 16 more ... | "toSeq">, "displayName" | ... 28 more ... | "toSeq">, "2">, _Pick<...>>?Do the
immutableAPI's still work even though the type is definition has changed to this?
@ctrlplusb yes That's what I'm confused about锛宐ecause i write some util function , them accept the type is User not _Merge just likeimport { User } from "../model/user";
const store = createStore(model, {});
const user = store.getState().user.user;
function checkUser(user: User) {}
checkUser(user); // type error
Hi @yongningfu
The latest 3.4.0 alpha release fixes this issue.
Let me know if it works for you. See #459 for more info. 馃憤
Hi @yongningfu
The latest 3.4.0 alpha release fixes this issue.
Let me know if it works for you. See #459 for more info. 馃憤
that's exactly what I need锛孖 wonder why the V4 Model API is abandoned. v4 pr, maybe Generics API design is more lightweight than Modal?
I abandoned v4 as the Model API was actually really annoying to use in practice and full of gotchas. I persisted with trying to solve the same problems it was solving with pure TypeScript typings magic and was luckily able to do so. Happy that we don't need to introduce a breaking change. I really want to keep breaking changes down to an absolute minimum based on the evolution and adoption of the library.
Most helpful comment
Hi @yongningfu
The latest 3.4.0 alpha release fixes this issue.
Let me know if it works for you. See #459 for more info. 馃憤