Comments (8)
Yes please, if it gets fixed (even if I have to change my type checking again) I would love to know. One of the major reasons we use MST is because it has nice strict pre-type checking which detects a LOT of bugs before it gets out to customers (our testers have caught so many string/number mismatch bugs thanks to MST). So while this particular issue ultimately was a lot smaller than the for instance the month or so it took to re-platform onto MST, having less strictness may allow a few bugs to slip by accident.
I'm completely ok if I need to change types or code to get back the previous limitations (especially if its a pathway to perhaps using typescript to be even more precise in the future). For instance all of our Maps use GUID/UUID keys and I know its technically possible to model that as a special typescript type that is a further subset of string.
As of right now the code is stable and I'm not really worried about things being introduced that may trickle in potential bugs for 2-4 weeks at this point, so I'm not really in a rush for a change, but it would be excellent if it is possible to better control the allowed types of the map so I can get back to string and maybe go further in the future.
Thanks for the response and the quick pointers to fix my problem!
from mobx-state-tree.
I will check and update today
from mobx-state-tree.
Hey @cambirch Can you share more about EntityRoot and ChildModel or share a codesandbox link??
from mobx-state-tree.
Absolutely. Had to start from a blank React + TS sandbox since the "official" one didn't want to import the typescript typings. Tried to imitate the official one as much as is reasonable while keeping it as simple as I could.
Error is on line 35 of index.tsx
from mobx-state-tree.
@cambirch this is due to maps changing a bunch of stuff from string to string|number in latest. this codesandbox fixes
https://codesandbox.io/s/serene-dan-swh4td
just made this one line change in your code
- KeyEntity extends keyof SubType<TEntity, Map<string, any>>,
+ KeyEntity extends keyof SubType<TEntity, Map<string|number, any>>,
related PR #2079 which i was also questioning #2079 (comment)
from mobx-state-tree.
Thanks for the quick response. I've got my codebase upgraded and the compiler is no longer failing. I didn't check that specific part of my type definitions because I had figured that was mine and not library level stuff so it shouldn't have been impacted.
I will say that I'm not sure I'm happy with the definition change because it makes it very loose for Map typing and I lose my control of being able to ensure strict enough typing to protect against unintentional bugs. I've now just introduced a significant quantity of potential bugs that typescript won't be detecting anymore.
I would be quite happy if the map type (types.map) was updated to include and <string|number> as available options instead of the current case. Then at least I would be changing a few hundred pieces of code in order to gain extra safety and future upgrade protections.
Anyways, thanks for figuring out the cause, I tried a lot of other cases including importing IMapType and such and nothing was solving.
from mobx-state-tree.
Hey @cambirch - I'm sorry to hear the typing changes caused so much friction for you.
I'm going to bring this up at the maintainer meeting for November and see if we can find a middle-ground here. Do you want me to ping you if/when we fix this up for you? Seems like a small change we could release as a patch.
Sorry again for the inconvenience!
from mobx-state-tree.
Hey @cambirch - thanks again for being understanding here. Just got off the maintainer call, and I think @chakrihacker is going to try and find a way where we can support both options here, but it's possible we are going to move forward with the change as-is in 5.3.0
, since it sounds like you were able to upgrade to our new types, and the change was in an effort to fix existing bug reports about the types. @chakrihacker said he'll have an update by Friday here.
One way or another, I still want to apologize to you. This is a tricky scenario since we have classified the prior behavior as a "bug" and "incorrect", but since it's been that way for so long, it's reasonable that you (and I imagine others) came to rely on that behavior, so when we released what we thought was a valid minor version, it broke on your end.
The big takeaway outside of this specific type, is that we are going to do some work to make implicit behavior explicit in the future, so we can be more mindful and communicate better about changes. Semantic versioning is only as useful as our own understanding of the existing state of the code base and its usage.
Thanks again, and we'll have one more update for you by the end of the week. Have a good one!
from mobx-state-tree.
Related Issues (20)
- RootStore type becomes "any" the moment we call a RootStore model action using yield on a child model action HOT 3
- Unintended behavior when creating new models with falsy first argument HOT 8
- detach can corrupt the identifierCache HOT 2
- Add tests and documentation for debug names in complex types
- Add tests and documentation for new parent argument to `types.optional` HOT 1
- Document how MST lazily creates objects HOT 1
- Use getTime() to check for Date equality HOT 8
- Remove Lerna config and lift MST sub-package up
- When observe() a MST node's primitive property, TypeScript get the wrong type of oldValue & newValue HOT 1
- Add safeMap utility (or something like it)
- TypeError: 0, _mobx.defineProperty is not a function (it is undefined) HOT 4
- applySnapshot is slow HOT 1
- Unexpected error "Сannot finalize the creation of a node that is already dead" while applying snapshot HOT 16
- Linters do not recognize `fail` as a required import in library code HOT 4
- REST - create data with server side ID HOT 2
- Better documentation on action/view definitions and their impact on IDE introspection, navigation and refactoring HOT 2
- Missing docs for `types.lazy` HOT 2
- getMembers does not work as expected, behaviour change between 5.1.0 and 5.4.1 HOT 11
- Model constructor modifies descriptor object HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobx-state-tree.