Skip to content

Commit

Permalink
fix ts3.5.1 test, update some dev deps (#1310)
Browse files Browse the repository at this point in the history
* fix ts3.51 test

* fix compilation
  • Loading branch information
xaviergonz committed Jun 5, 2019
1 parent 1906a39 commit 57e7ad0
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 165 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { types, getEnv, getParent, getPath, cast } from "../../src"
import { types, getEnv, getParent, getPath, cast, Instance } from "../../src"

const ChildModel = types
.model("Child", {
Expand All @@ -8,7 +8,7 @@ const ChildModel = types
})
.views(self => {
return {
get parent() {
get parent(): IParentModelInstance {
return getParent<typeof ParentModel>(self)
}
}
Expand All @@ -22,6 +22,7 @@ const ChildModel = types
self.parentPropertyIsNullAfterAttach = typeof self.parent.fetch === "undefined"
}
}))

const ParentModel = types
.model("Parent", {
child: types.optional(ChildModel, {})
Expand All @@ -32,6 +33,8 @@ const ParentModel = types
}
}))

interface IParentModelInstance extends Instance<typeof ParentModel> {}

// NOTE: parents are now always created before children;
// moreover, we do not actually have actions hash during object-node creation
test("Parent property have value during child's afterCreate() event", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mobx-state-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"rollup-plugin-filesize": "^6.0.1",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-terser": "^5.0.0",
"shx": "^0.3.2",
"ts-jest": "^24.0.0",
"ts-node": "^8.0.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/mobx-state-tree/src/types/complex-types/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,15 @@ export class MapType<IT extends IAnyType> extends ComplexType<
}

getSnapshot(node: this["N"]): this["S"] {
const res: this["S"] = {}
const res: any = {}
node.getChildren().forEach(childNode => {
res[childNode.subpath] = childNode.snapshot
})
return res
}

processInitialSnapshot(childNodes: IChildNodesMap): this["S"] {
const processed: this["S"] = {}
const processed: any = {}
Object.keys(childNodes).forEach(key => {
processed[key] = childNodes[key].getSnapshot()
})
Expand Down
4 changes: 2 additions & 2 deletions packages/mobx-state-tree/src/types/complex-types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,15 @@ export class ModelType<
if (!(patch.op === "replace" || patch.op === "add")) {
throw fail(`object does not support operation ${patch.op}`)
}
node.storedValue[subpath] = patch.value
;(node.storedValue as any)[subpath] = patch.value
}

@action
applySnapshot(node: this["N"], snapshot: this["C"]): void {
const preProcessedSnapshot = this.applySnapshotPreProcessor(snapshot)
typecheckInternal(this, preProcessedSnapshot)
this.forAllProps(name => {
node.storedValue[name] = preProcessedSnapshot[name]
;(node.storedValue as any)[name] = preProcessedSnapshot[name]
})
}

Expand Down
4 changes: 2 additions & 2 deletions packages/mobx-state-tree/src/types/utility-types/late.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Late<IT extends IAnyType> extends BaseType<
environment: any,
initialValue: this["C"] | this["T"]
): this["N"] {
return this.getSubType(true).instantiate(parent, subpath, environment, initialValue)
return this.getSubType(true).instantiate(parent, subpath, environment, initialValue) as any
}

reconcile(
Expand All @@ -72,7 +72,7 @@ class Late<IT extends IAnyType> extends BaseType<
parent: AnyObjectNode,
subpath: string
): this["N"] {
return this.getSubType(true).reconcile(current, newValue, parent, subpath)
return this.getSubType(true).reconcile(current, newValue, parent, subpath) as any
}

describe() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Refinement<IT extends IAnyType> extends BaseType<
initialValue: this["C"] | this["T"]
): this["N"] {
// create the child type
return this._subtype.instantiate(parent, subpath, environment, initialValue)
return this._subtype.instantiate(parent, subpath, environment, initialValue) as any
}

isAssignableFrom(type: IAnyType) {
Expand All @@ -73,7 +73,7 @@ class Refinement<IT extends IAnyType> extends BaseType<
parent: AnyObjectNode,
subpath: string
): this["N"] {
return this._subtype.reconcile(current, newValue, parent, subpath)
return this._subtype.reconcile(current, newValue, parent, subpath) as any
}

getSubTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ class SnapshotProcessor<IT extends IAnyType, CustomC, CustomS> extends BaseType<
const processedInitialValue = isStateTreeNode(initialValue)
? initialValue
: this.preProcessSnapshot(initialValue)
const node = this._subtype.instantiate(parent, subpath, environment, processedInitialValue)
const node = this._subtype.instantiate(
parent,
subpath,
environment,
processedInitialValue
) as any
this._fixNode(node)
return node
}
Expand All @@ -100,7 +105,7 @@ class SnapshotProcessor<IT extends IAnyType, CustomC, CustomS> extends BaseType<
isStateTreeNode(newValue) ? newValue : this.preProcessSnapshot(newValue),
parent,
subpath
)
) as any
if (node !== current) {
this._fixNode(node)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mst-middlewares/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"rollup-plugin-filesize": "^6.0.1",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-terser": "^5.0.0",
"ts-jest": "^24.0.0",
"tslib": "^1.9.3",
"typescript": "^3.3.3333"
Expand Down

0 comments on commit 57e7ad0

Please sign in to comment.