-
Notifications
You must be signed in to change notification settings - Fork 5
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
Recursive type maximum call stack exceeded #11
Comments
@jjrv can you fix it or explain how it can be fixed in classy-mst, please? |
It looks like a recursive type: |
But with types.late typescript don't complain about circular type. There is only runtime error because of incorrect handling of maybeNull, I think. |
I found that a slightly improved fix to #8 also would fix this, however while disabling polymorphism support for the The diff of - let Model = Data.preProcessSnapshot(
- // Instantiating a union of models requires a snapshot.
- (snap: any) => snap || {}
- ).postProcessSnapshot((snap: any) => {
+ let Model = Data.postProcessSnapshot((snap: any) => {
- return(polymorphic(Code, Model, modelName));
+ return(Model as any); Can you test it? I'll need to add a new options object to allow toggling this fix on/off. |
Actually it seems a |
Sooo, what is the final fix? Just remove |
Try and see if it works for you. Seems to still cause some tests to fail. I'll fix this one way or another and release a new version. Disabling polymorphism for the type may still be necessary. |
Ok, i'll try it. |
Yeah, removing of Anyway, I already refactor my |
OK, version 3.5.0 is out. It now works with a flag: export const Message = mst(MessageCode, MessageData, 'Message', { sealed: true }) |
Thanks for reporting! |
This code (in pure mst) works well:
But this code is failing (when creating from snapshot):
The text was updated successfully, but these errors were encountered: