@@ -7,7 +7,7 @@ const cloneDeep = require("lodash.clonedeep")
77
88function reportChange ( change :IDebugChange ) {
99if ( globalState . currentDebugOutputAction ) {
10- globalState . currentDebugOutputAction . changeList . push ( change )
10+ globalState ! . currentDebugOutputAction ! . changeList ! . push ( change )
1111} else { // Changes out of Action.
1212globalState . event . emit ( "debug" , {
1313id :createUniqueId ( ) ,
@@ -31,14 +31,14 @@ function getCallStack(target: object) {
3131const parentInfo = globalState . parentInfo . get ( currentTarget )
3232
3333// add key to call stack
34- callStack . unshift ( parentInfo . key )
34+ callStack . unshift ( parentInfo ! . key )
3535
3636// If has no parent's parent, add parent's name to call stack.
37- if ( ! globalState . parentInfo . has ( parentInfo . parent ) ) {
38- callStack . unshift ( parentInfo . parent . constructor . name )
37+ if ( ! globalState . parentInfo . has ( parentInfo ! . parent ) ) {
38+ callStack . unshift ( parentInfo ! . parent . constructor . name )
3939}
4040
41- currentTarget = parentInfo . parent
41+ currentTarget = parentInfo ! . parent
4242
4343runCount ++
4444if ( runCount >= globalState . getCallstackMaxCount ) {
@@ -58,10 +58,10 @@ globalState.event.on("get", info => {
5858return
5959}
6060
61- if ( info . value !== null && typeof info . value === "object" ) {
62- globalState . parentInfo . set ( info . value , {
63- parent :info . target ,
64- key :info . key
61+ if ( info ! . value !== null && typeof info ! . value === "object" ) {
62+ globalState . parentInfo . set ( info ! . value , {
63+ parent :info ! . target ,
64+ key :info ! . key
6565} )
6666}
6767} )
@@ -102,7 +102,7 @@ globalState.event.on("startBatch", () => {
102102
103103// 如果当前深度大于 1,就作为加到父级的 changeList
104104if ( globalState . batchDeep > 1 ) {
105- globalState . debugOutputActionMapBatchDeep . get ( globalState . batchDeep - 1 ) . changeList . push ( {
105+ globalState ! . debugOutputActionMapBatchDeep ! . get ( globalState . batchDeep - 1 ) ! . changeList ! . push ( {
106106type :"action" ,
107107action :debugOutputBundleAction
108108} )
@@ -118,10 +118,10 @@ globalState.event.on("endBatch", () => {
118118}
119119
120120// 每次出栈,都要更新 currentDebugOutputAction
121- globalState . currentDebugOutputAction = globalState . debugOutputActionMapBatchDeep . get ( globalState . batchDeep )
121+ globalState . currentDebugOutputAction = globalState . debugOutputActionMapBatchDeep . get ( globalState . batchDeep ) || null
122122
123123if ( ! inAction ( ) ) {
124- let cloneDebugInfo :IDebugInfo = null
124+ let cloneDebugInfo :IDebugInfo | null = null
125125
126126try {
127127cloneDebugInfo = JSON . parse ( JSON . stringify ( globalState . debugOutputActionMapBatchDeep . get ( 1 ) ) )
@@ -146,14 +146,14 @@ globalState.event.on("set", info => {
146146return
147147}
148148
149- const callStack = getCallStack ( info . target )
149+ const callStack = getCallStack ( info ! . target )
150150
151151reportChange ( {
152152type :"change" ,
153153 callStack,
154- oldValue :cloneDeep ( info . oldValue ) ,
155- key :info . key ,
156- value :cloneDeep ( info . value )
154+ oldValue :cloneDeep ( info ! . oldValue ) ,
155+ key :info ! . key ,
156+ value :cloneDeep ( info ! . value )
157157} )
158158} )
159159
@@ -165,11 +165,11 @@ globalState.event.on("deleteProperty", info => {
165165return
166166}
167167
168- const callStack = getCallStack ( info . target )
168+ const callStack = getCallStack ( info ! . target )
169169
170170reportChange ( {
171171type :"delete" ,
172172 callStack,
173- key :info . key ,
173+ key :info ! . key ,
174174} )
175175} )