@jbrowse/mobx-state-tree 5.10.2 → 5.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,4 +24,4 @@ Fork of mobx-state-tree v5.4.2 for use in jbrowse
24
24
  - replaced `unique symbol` phantom properties (`$emptyObject`, `$stateTreeNodeType`) with
25
25
  exported string-keyed brand interfaces (`$EmptyObjectBrand`, `$__mstStateTreeNodeType__`),
26
26
  fixing tsgo TS4058/TS4023 errors when MST types propagate into exported function return types
27
- - add reflection api getChildType
27
+ - add reflection api getChildType and getUnionSubtypes and getDefaultInstanceOrSnapshot
package/dist/index.d.ts CHANGED
@@ -732,9 +732,14 @@ interface IType<C, S, T> {
732
732
  /**
733
733
  * Creates an instance for the type given an snapshot input.
734
734
  *
735
+ * The snapshot argument is required when the creation type has at least one
736
+ * required member (`{} extends C` is false) and optional otherwise, so e.g.
737
+ * `types.model({ a: types.string }).create()` is a compile error rather than a
738
+ * runtime throw, while `types.model().create()` stays valid.
739
+ *
735
740
  * @returns An instance of that type.
736
741
  */
737
- create(snapshot?: C, env?: any): this["Type"];
742
+ create(...args: {} extends C ? [snapshot?: C, env?: any] : [snapshot: C, env?: any]): this["Type"];
738
743
  /**
739
744
  * Checks if a given snapshot / instance is of the given type.
740
745
  *
@@ -1678,9 +1683,9 @@ type ModelCreationType<PC> = MaybeEmpty<{
1678
1683
  /** @hidden */
1679
1684
  type ModelCreationType2<P extends ModelProperties, CustomC> = MaybeEmpty<_CustomOrOther<CustomC, ModelCreationType<ExtractCFromProps<P>>>>;
1680
1685
  /** @hidden */
1681
- type ModelSnapshotType<P extends ModelProperties> = MaybeEmpty<{
1686
+ type ModelSnapshotType<P extends ModelProperties> = {
1682
1687
  [K in keyof P]: P[K]["SnapshotType"];
1683
- }>;
1688
+ };
1684
1689
  /** @hidden */
1685
1690
  type ModelSnapshotType2<P extends ModelProperties, CustomS> = _CustomOrOther<CustomS, ModelSnapshotType<P>>;
1686
1691
  /**
@@ -1711,7 +1716,7 @@ interface IModelType<PROPS extends ModelProperties, OTHERS, CustomC = _NotCustom
1711
1716
  views?: V;
1712
1717
  state?: VS;
1713
1718
  }): IModelType<PROPS, OTHERS & A & V & VS, CustomC, CustomS>;
1714
- preProcessSnapshot<NewC = ModelCreationType2<PROPS, CustomC>>(fn: (snapshot: NewC) => ModelCreationType2<PROPS, CustomC>): IModelType<PROPS, OTHERS, NewC, CustomS>;
1719
+ preProcessSnapshot<NewC = ModelCreationType2<PROPS, CustomC>>(fn: (snapshot: NewC) => ModelCreationType2<PROPS, CustomC> | NewC): IModelType<PROPS, OTHERS, CustomC, CustomS>;
1715
1720
  postProcessSnapshot<NewS = ModelSnapshotType2<PROPS, CustomS>>(fn: (snapshot: ModelSnapshotType2<PROPS, CustomS>) => NewS): IModelType<PROPS, OTHERS, CustomC, NewS>;
1716
1721
  }
1717
1722
  /**