@@ -49,6 +49,8 @@ class RemoveAsserts {
49
49
}
50
50
51
51
visitNode ( node : ts . Node ) : ts . Node {
52
+ let updatedNode : ts . Node | null = null ;
53
+
52
54
if ( ts . isCallExpression ( node ) ) {
53
55
const signature = this . typeChecker . getResolvedSignature ( node ) ;
54
56
if (
@@ -63,19 +65,31 @@ class RemoveAsserts {
63
65
) {
64
66
const method = declaration . name ! . text ;
65
67
if ( method === 'debugAssert' ) {
66
- return ts . createEmptyStatement ( ) ;
68
+ updatedNode = ts . createEmptyStatement ( ) ;
67
69
} else if ( method === 'hardAssert' ) {
68
70
// Remove the log message but keep the assertion
69
- return ts . createCall ( declaration . name ! , /*typeArgs*/ undefined , [
70
- node . arguments [ 0 ]
71
- ] ) ;
71
+ updatedNode = ts . createCall (
72
+ declaration . name ! ,
73
+ /*typeArgs*/ undefined ,
74
+ [ node . arguments [ 0 ] ]
75
+ ) ;
72
76
} else if ( method === 'fail' ) {
73
77
// Remove the log message
74
- return ts . createCall ( declaration . name ! , /*typeArgs*/ undefined , [ ] ) ;
78
+ updatedNode = ts . createCall (
79
+ declaration . name ! ,
80
+ /*typeArgs*/ undefined ,
81
+ [ ]
82
+ ) ;
75
83
}
76
84
}
77
85
}
78
86
}
79
- return node ;
87
+
88
+ if ( updatedNode ) {
89
+ ts . setSourceMapRange ( updatedNode , ts . getSourceMapRange ( node ) ) ;
90
+ return updatedNode ;
91
+ } else {
92
+ return node ;
93
+ }
80
94
}
81
95
}
0 commit comments