@@ -25,7 +25,7 @@ namespace ts {
25
25
return new ( IdentifierConstructor || ( IdentifierConstructor = objectAllocator . getIdentifierConstructor ( ) ) ) ( kind , pos , end ) ;
26
26
}
27
27
else if ( ! isNodeKind ( kind ) ) {
28
- return new ( TokenConstructor || ( TokenConstructor = objectAllocator . getTokenConstructor ( ) ) ) ( kind , pos , end ) ;
28
+ return new ( TokenConstructor || ( TokenConstructor = objectAllocator . getTokenConstructor ( ) ) ) ( kind as SyntaxKind , pos , end ) ;
29
29
}
30
30
else {
31
31
return new ( NodeConstructor || ( NodeConstructor = objectAllocator . getNodeConstructor ( ) ) ) ( kind , pos , end ) ;
@@ -93,12 +93,13 @@ namespace ts {
93
93
case SyntaxKind . BindingElement :
94
94
return visitNodes ( cbNode , cbNodes , node . decorators ) ||
95
95
visitNodes ( cbNode , cbNodes , node . modifiers ) ||
96
- visitNode ( cbNode , ( < VariableLikeDeclaration > node ) . propertyName ) ||
97
- visitNode ( cbNode , ( < VariableLikeDeclaration > node ) . dotDotDotToken ) ||
98
- visitNode ( cbNode , ( < VariableLikeDeclaration > node ) . name ) ||
99
- visitNode ( cbNode , ( < VariableLikeDeclaration > node ) . questionToken ) ||
100
- visitNode ( cbNode , ( < VariableLikeDeclaration > node ) . type ) ||
101
- visitNode ( cbNode , ( < VariableLikeDeclaration > node ) . initializer ) ;
96
+ // TODO: Specialize, remove casts to VariableLikeDeclarationBase
97
+ visitNode ( cbNode , ( < VariableLikeDeclarationBase > node ) . propertyName ) ||
98
+ visitNode ( cbNode , ( < VariableLikeDeclarationBase > node ) . dotDotDotToken ) ||
99
+ visitNode ( cbNode , ( < VariableLikeDeclarationBase > node ) . name ) ||
100
+ visitNode ( cbNode , ( < VariableLikeDeclarationBase > node ) . questionToken ) ||
101
+ visitNode ( cbNode , ( < VariableLikeDeclarationBase > node ) . type ) ||
102
+ visitNode ( cbNode , ( < VariableLikeDeclarationBase > node ) . initializer ) ;
102
103
case SyntaxKind . FunctionType :
103
104
case SyntaxKind . ConstructorType :
104
105
case SyntaxKind . CallSignature :
@@ -298,9 +299,9 @@ namespace ts {
298
299
case SyntaxKind . InterfaceDeclaration :
299
300
return visitNodes ( cbNode , cbNodes , node . decorators ) ||
300
301
visitNodes ( cbNode , cbNodes , node . modifiers ) ||
301
- visitNode ( cbNode , ( < InterfaceDeclaration > node ) . name ) ||
302
- visitNodes ( cbNode , cbNodes , ( < InterfaceDeclaration > node ) . typeParameters ) ||
303
- visitNodes ( cbNode , cbNodes , ( < ClassDeclaration > node ) . heritageClauses ) ||
302
+ visitNode ( cbNode , node . name ) ||
303
+ visitNodes ( cbNode , cbNodes , node . typeParameters ) ||
304
+ visitNodes ( cbNode , cbNodes , node . heritageClauses ) ||
304
305
visitNodes ( cbNode , cbNodes , ( < InterfaceDeclaration > node ) . members ) ;
305
306
case SyntaxKind . TypeAliasDeclaration :
306
307
return visitNodes ( cbNode , cbNodes , node . decorators ) ||
@@ -1089,7 +1090,7 @@ namespace ts {
1089
1090
1090
1091
function parseExpectedToken < TKind extends SyntaxKind > ( t : TKind , reportAtCurrentPosition : boolean , diagnosticMessage : DiagnosticMessage , arg0 ?: any ) : Token < TKind > ;
1091
1092
function parseExpectedToken ( t : SyntaxKind , reportAtCurrentPosition : boolean , diagnosticMessage : DiagnosticMessage , arg0 ?: any ) : Node {
1092
- return parseOptionalToken ( t ) ||
1093
+ return parseOptionalToken ( t ) as Node ||
1093
1094
createMissingNode ( t , reportAtCurrentPosition , diagnosticMessage , arg0 ) ;
1094
1095
}
1095
1096
@@ -1180,7 +1181,7 @@ namespace ts {
1180
1181
( result as LiteralLikeNode ) . text = "" ;
1181
1182
}
1182
1183
1183
- return finishNode ( result ) as T ;
1184
+ return finishNode ( result as Node ) as T ;
1184
1185
}
1185
1186
1186
1187
function internIdentifier ( text : string ) : string {
@@ -1609,11 +1610,11 @@ namespace ts {
1609
1610
1610
1611
// Ok, we have a node that looks like it could be reused. Now verify that it is valid
1611
1612
// in the current list parsing context that we're currently at.
1612
- if ( ! canReuseNode ( node , parsingContext ) ) {
1613
+ if ( ! canReuseNode ( node as Node , parsingContext ) ) {
1613
1614
return undefined ;
1614
1615
}
1615
1616
1616
- return node ;
1617
+ return node as Node ;
1617
1618
}
1618
1619
1619
1620
function consumeNode ( node : Node ) {
@@ -6970,23 +6971,23 @@ namespace ts {
6970
6971
6971
6972
function moveElementEntirelyPastChangeRange ( element : IncrementalElement , isArray : boolean , delta : number , oldText : string , newText : string , aggressiveChecks : boolean ) {
6972
6973
if ( isArray ) {
6973
- visitArray ( < IncrementalNodeArray > element ) ;
6974
+ visitArray ( < NodeArray < Node > > < IncrementalNodeArray > element ) ;
6974
6975
}
6975
6976
else {
6976
- visitNode ( < IncrementalNode > element ) ;
6977
+ visitNode ( < Node > < IncrementalNode > element ) ;
6977
6978
}
6978
6979
return ;
6979
6980
6980
- function visitNode ( node : IncrementalNode ) {
6981
+ function visitNode ( node : Node ) {
6981
6982
let text = "" ;
6982
6983
if ( aggressiveChecks && shouldCheckNode ( node ) ) {
6983
6984
text = oldText . substring ( node . pos , node . end ) ;
6984
6985
}
6985
6986
6986
6987
// Ditch any existing LS children we may have created. This way we can avoid
6987
6988
// moving them forward.
6988
- if ( node . _children ) {
6989
- node . _children = undefined ;
6989
+ if ( ( node as IncrementalNode ) . _children ) {
6990
+ ( node as IncrementalNode ) . _children = undefined ;
6990
6991
}
6991
6992
6992
6993
node . pos += delta ;
@@ -6996,7 +6997,7 @@ namespace ts {
6996
6997
Debug . assert ( text === newText . substring ( node . pos , node . end ) ) ;
6997
6998
}
6998
6999
6999
- forEachChild ( node , visitNode , visitArray ) ;
7000
+ forEachChild ( node as Node , visitNode , visitArray ) ;
7000
7001
if ( hasJSDocNodes ( node ) ) {
7001
7002
for ( const jsDocComment of node . jsDoc ) {
7002
7003
forEachChild ( jsDocComment , visitNode , visitArray ) ;
@@ -7005,8 +7006,8 @@ namespace ts {
7005
7006
checkNodePositions ( node , aggressiveChecks ) ;
7006
7007
}
7007
7008
7008
- function visitArray ( array : IncrementalNodeArray ) {
7009
- array . _children = undefined ;
7009
+ function visitArray ( array : NodeArray < Node > ) {
7010
+ ( array as IncrementalNodeArray ) . _children = undefined ;
7010
7011
array . pos += delta ;
7011
7012
array . end += delta ;
7012
7013
@@ -7016,7 +7017,7 @@ namespace ts {
7016
7017
}
7017
7018
}
7018
7019
7019
- function shouldCheckNode ( node : Node ) {
7020
+ function shouldCheckNode ( node : BaseNode ) {
7020
7021
switch ( node . kind ) {
7021
7022
case SyntaxKind . StringLiteral :
7022
7023
case SyntaxKind . NumericLiteral :
@@ -7145,9 +7146,9 @@ namespace ts {
7145
7146
7146
7147
// Adjust the pos or end (or both) of the intersecting element accordingly.
7147
7148
adjustIntersectingElement ( child , changeStart , changeRangeOldEnd , changeRangeNewEnd , delta ) ;
7148
- forEachChild ( child , visitNode , visitArray ) ;
7149
+ forEachChild ( child as Node , visitNode as ( n : Node ) => undefined , visitArray as ( n : NodeArray < Node > ) => undefined ) ;
7149
7150
7150
- checkNodePositions ( child , aggressiveChecks ) ;
7151
+ checkNodePositions ( child as Node , aggressiveChecks ) ;
7151
7152
return ;
7152
7153
}
7153
7154
@@ -7336,7 +7337,7 @@ namespace ts {
7336
7337
_children : Node [ ] ;
7337
7338
}
7338
7339
7339
- export interface IncrementalNode extends Node , IncrementalElement {
7340
+ export interface IncrementalNode extends BaseNode , IncrementalElement {
7340
7341
hasBeenIncrementallyParsed : boolean ;
7341
7342
}
7342
7343
0 commit comments