-
Notifications
You must be signed in to change notification settings - Fork 0
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
MobX, MST, TypeScript, Jest, TSLint upgrade (#2811, #2971) #2995
Conversation
@southerneer Feel free to continue upgrade. I upgraded all(?) typescript-related libraries including ts-jest, but now jest tests fail with 'Unexpected token import' |
UPDATE: I've fixed jest I changed homeStore.test.ts to pass references correctly (i.e. add bot to some test model, so references could work), but the solution looks overcomplicated. Feel free to use simpler method if you can. |
I started down the path of converting Jest snapshot tests from js -> tsx and eventually realized that |
Any ideas? |
Unit tests fail for the same reason as homeStore - MST 2 allows to store real instances as references, but MST 3 - doesn't (so 'detached' paging results works fine with MST2 but not with MST3). My future attempts to solve this: #3003. I decide to make it as separate PR because my attempt ends with big mess with typescript, many typings just lost (Profile/Bot), probably because of circular references: So probably we should stay with MST 2 for a while.. |
WIP: #2811 introduce circular types
const data = {...param} | ||
// some workaround to create references on the fly (maybe recent MST can do it automatically?) | ||
if (param.user && typeof param.user === 'object') { | ||
// create reference to profile! | ||
self.profiles.get(param.user.id, param.user) | ||
data.user = param.user.id | ||
} | ||
if (param.profile && typeof param.profile === 'object') { | ||
// create reference to profile! |
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.
This "manual" switching from object
to MST ref seems really dirty. Once we switch to all GraphQL we can use __typename
to manage this with a little more flexibility but even still that seems like a hack. It seems like there should be a better way to dynamically inspect an incoming object for MST references.
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.
It is dirty, I agree, but I don't see better option
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.
Created #3011
Once we have some idea, we can do it.
@southerneer Merging, feel free to review |
@@ -8,6 +8,7 @@ import {Timeable} from './Timeable' | |||
import {Profile} from './Profile' | |||
// import {ProfileRef} from './Profile' | |||
|
|||
const BotPostProfileRef = types.late('LazyProfileRef', (): IAnyModelType => Profile) |
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.
Nice!
No description provided.