Repository navigation
Type create/validate to accept an instance type - #2199
Conversation
|
Hold off on a final review. I realized our tsconfig isn't properly typechecking tests, and this introduces a typing bug: it allows passing in a value for a view in model types. Technically this works (it just gets ignored) but I'm thinking ideally we make it fail typechecking so users avoid making that error. This is actually tough to do, but I think we can do this by marking the getters as readonly and excluding those from the instance type in I'm going to play with that idea, and if it works out, great! If it doesn't, I think I may remove the one test that's failing: Do let me know if you think the tests I've added are comprehensive enough though! Want to make sure we have confidence in this change. |
6176e94 to
e1b5068
Compare
|
Will rebase this after #2200 merged, which should fix the typechecking / build stuff |
e1b5068 to
f893791
Compare
|
@coolsoftwaretyler this is good for review now! <3 I was thinking we could also get this one in for #2201 |
|
Perfect! Great idea. Will take a look sometime this week and get this into the next preview release. |
|
Alright, looks excellent and we will get this into the v7 preview. I think we'll consider this a breaking change, even though it should mostly be backwards compatible. I think type changes are just best treated as breaks overall, in case people are relying on the old type behavior. |
- mobxjs#1458 REPRODUCES: safeReference invalidates when an old subtree with the same id is destroyed; a guard test shows a skip-only fix is not enough, the watcher must move to the node the id now resolves to. - mobxjs#1778 REPRODUCES (types): resolveIdentifier's type parameter rejects snapshotProcessor types. - mobxjs#1760 ALREADY_FIXED by mobxjs#2199. - mobxjs#1291 CANNOT_REPRODUCE and likely obsolete: the quoted error is the MobX 4/5 computationDepth invariant, which MobX 7 no longer has. - mobxjs#2255 CANNOT_REPRODUCE: thread has no runnable code; blockers listed. Also records the fixing commits for the earlier mobxjs#1297 (mobxjs#1581), mobxjs#1738 and mobxjs#1640 (mobxjs#2199) tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
All six reproduce; each file compiles today and typecheck fails when the defect is fixed, via @ts-expect-error BUG markers. - mobxjs#1403, mobxjs#2216, mobxjs#2253: props and compose use plain intersections, so an optional override of a required prop stays required or becomes never. Re-landing an Omit-based override reopens the mobxjs#2230 depth trade-off (mobxjs#2218 reverted by mobxjs#2234); compose overloads need the same change. - mobxjs#1463: create() accepts any object because ExcludeReadonly (from mobxjs#2199) is an indexed access over WritableKeys; the fix only tightens. - mobxjs#1157: one directive is the reported inference limit on an unannotated circular view; ten others are the same mobxjs#2199 regression and flip when WritableKeys stops being evaluated eagerly. - mobxjs#1367: .props after preProcessSnapshot never adds new props to the declared snapshot type. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

What does this PR do and why?
We've had issues with typings when instantiating references
#1568 for example, and maybe even #1764.
This PR resolves that by typing
createto accept an instance type. I've added a "kitchen sink" test for create to test both snapshots and instances.Steps to validate locally
The test added in this PR will type issues (like in above the screenshot) if you revert 6176e94.