Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
Merge 30a6283 into 12f6d81
Browse files Browse the repository at this point in the history
  • Loading branch information
ktutnik committed Oct 24, 2019
2 parents 12f6d81 + 30a6283 commit 5c9f38f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Result {
}

interface ParentInfo {
value: any,
type: Class
decorators: any[]
}
Expand Down Expand Up @@ -102,7 +103,7 @@ function objectVisitor(value: any, ast: ObjectNode, opt: VisitorOption): Result
const node = ast.properties.get(property.name) as SuperNode
const option = {
path: getPath(opt.path, property.name), extension: opt.extension,
decorators: property.decorators, parent: { type: ast.type, decorators: opt.decorators },
decorators: property.decorators, parent: { value, type: ast.type, decorators: opt.decorators },
guessArrayElement: opt.guessArrayElement
}
const propValue = pipeline(value[property.name], node, option)
Expand Down
50 changes: 50 additions & 0 deletions test/__snapshots__/visitor.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ Object {
"parent": Object {
"decorators": Array [],
"type": Tag,
"value": Object {
"age": "12",
},
},
"result": 12,
},
Expand All @@ -160,6 +163,11 @@ Object {
"parent": Object {
"decorators": Array [],
"type": Animal,
"value": Object {
"tag": Object {
"age": "12",
},
},
},
"result": Tag {
"age": Object {
Expand All @@ -170,6 +178,9 @@ Object {
},
],
"type": Tag,
"value": Object {
"age": "12",
},
},
"result": 12,
},
Expand All @@ -189,12 +200,32 @@ Object {
"parent": Object {
"decorators": Array [],
"type": Animal,
"value": Object {
"tag": Array [
Object {
"age": "12",
},
Object {
"age": "12",
},
],
},
},
"result": Array [
Object {
"parent": Object {
"decorators": Array [],
"type": Animal,
"value": Object {
"tag": Array [
Object {
"age": "12",
},
Object {
"age": "12",
},
],
},
},
"result": Tag {
"age": Object {
Expand All @@ -209,6 +240,9 @@ Object {
},
],
"type": Tag,
"value": Object {
"age": "12",
},
},
"result": 12,
},
Expand All @@ -218,6 +252,16 @@ Object {
"parent": Object {
"decorators": Array [],
"type": Animal,
"value": Object {
"tag": Array [
Object {
"age": "12",
},
Object {
"age": "12",
},
],
},
},
"result": Tag {
"age": Object {
Expand All @@ -232,6 +276,9 @@ Object {
},
],
"type": Tag,
"value": Object {
"age": "12",
},
},
"result": 12,
},
Expand All @@ -257,6 +304,9 @@ Object {
},
],
"type": Tag,
"value": Object {
"age": "12",
},
},
"result": 12,
},
Expand Down

0 comments on commit 5c9f38f

Please sign in to comment.