@@ -170,6 +170,10 @@ namespace ts {
170
170
case SyntaxKind . ElementAccessExpression :
171
171
return visitNode ( cbNode , ( < ElementAccessExpression > node ) . expression ) ||
172
172
visitNode ( cbNode , ( < ElementAccessExpression > node ) . argumentExpression ) ;
173
+ case SyntaxKind . TypeCall :
174
+ return visitNode ( cbNode , ( < TypeCallTypeNode > node ) . type ) ||
175
+ visitNodes ( cbNode , cbNodes , ( < TypeCallTypeNode > node ) . typeArguments ) ||
176
+ visitNodes ( cbNode , cbNodes , ( < TypeCallTypeNode > node ) . arguments ) ;
173
177
case SyntaxKind . CallExpression :
174
178
case SyntaxKind . NewExpression :
175
179
return visitNode ( cbNode , ( < CallExpression > node ) . expression ) ||
@@ -2738,8 +2742,8 @@ namespace ts {
2738
2742
return token ( ) === SyntaxKind . CloseParenToken || isStartOfParameter ( ) || isStartOfType ( ) ;
2739
2743
}
2740
2744
2741
- function parseJSDocPostfixTypeOrHigher ( ) : TypeNode {
2742
- const type = parseNonArrayType ( ) ;
2745
+ function parseJSDocPostfixTypeOrHigher ( typeNode ?: TypeNode ) : TypeNode {
2746
+ const type = typeNode || parseNonArrayType ( ) ;
2743
2747
const kind = getKind ( token ( ) ) ;
2744
2748
if ( ! kind ) return type ;
2745
2749
nextToken ( ) ;
@@ -2761,8 +2765,8 @@ namespace ts {
2761
2765
}
2762
2766
}
2763
2767
2764
- function parseArrayTypeOrHigher ( ) : TypeNode {
2765
- let type = parseJSDocPostfixTypeOrHigher ( ) ;
2768
+ function parseArrayTypeOrHigher ( typeNode ?: TypeNode ) : TypeNode {
2769
+ let type = parseJSDocPostfixTypeOrHigher ( typeNode ) ;
2766
2770
while ( ! scanner . hasPrecedingLineBreak ( ) && parseOptional ( SyntaxKind . OpenBracketToken ) ) {
2767
2771
if ( isStartOfType ( ) ) {
2768
2772
const node = < IndexedAccessTypeNode > createNode ( SyntaxKind . IndexedAccessType , type . pos ) ;
@@ -2794,7 +2798,7 @@ namespace ts {
2794
2798
case SyntaxKind . KeyOfKeyword :
2795
2799
return parseTypeOperator ( SyntaxKind . KeyOfKeyword ) ;
2796
2800
}
2797
- return parseArrayTypeOrHigher ( ) ;
2801
+ return parseTypeCallRest ( ) ;
2798
2802
}
2799
2803
2800
2804
function parseUnionOrIntersectionType ( kind : SyntaxKind . UnionType | SyntaxKind . IntersectionType , parseConstituentType : ( ) => TypeNode , operator : SyntaxKind . BarToken | SyntaxKind . AmpersandToken ) : TypeNode {
@@ -4240,6 +4244,46 @@ namespace ts {
4240
4244
}
4241
4245
}
4242
4246
4247
+ // type equivalent of parseCallExpressionRest
4248
+ function parseTypeCallRest ( type ?: TypeNode ) : TypeNode {
4249
+ while ( true ) {
4250
+ type = parseArrayTypeOrHigher ( type ) ;
4251
+ if ( token ( ) === SyntaxKind . LessThanToken ) {
4252
+ // See if this is the start of a generic invocation. If so, consume it and
4253
+ // keep checking for postfix expressions. Otherwise, it's just a '<' that's
4254
+ // part of an arithmetic expression. Break out so we consume it higher in the
4255
+ // stack.
4256
+ const typeArguments = tryParse ( parseTypeArgumentsInExpression ) ;
4257
+ if ( ! typeArguments ) {
4258
+ return type ;
4259
+ }
4260
+
4261
+ const callExpr = < TypeCallTypeNode > createNode ( SyntaxKind . TypeCall , type . pos ) ;
4262
+ callExpr . type = type ;
4263
+ callExpr . typeArguments = typeArguments ;
4264
+ callExpr . arguments = parseTypeArgumentList ( ) ;
4265
+ type = finishNode ( callExpr ) ;
4266
+ continue ;
4267
+ }
4268
+ else if ( token ( ) === SyntaxKind . OpenParenToken ) {
4269
+ const callExpr = < TypeCallTypeNode > createNode ( SyntaxKind . TypeCall , type . pos ) ;
4270
+ callExpr . type = type ;
4271
+ callExpr . arguments = parseTypeArgumentList ( ) ;
4272
+ type = finishNode ( callExpr ) ;
4273
+ continue ;
4274
+ }
4275
+
4276
+ return type ;
4277
+ }
4278
+ }
4279
+
4280
+ function parseTypeArgumentList ( ) {
4281
+ parseExpected ( SyntaxKind . OpenParenToken ) ;
4282
+ const result = parseDelimitedList ( ParsingContext . TypeArguments , parseType ) ;
4283
+ parseExpected ( SyntaxKind . CloseParenToken ) ;
4284
+ return result ;
4285
+ }
4286
+
4243
4287
function parseCallExpressionRest ( expression : LeftHandSideExpression ) : LeftHandSideExpression {
4244
4288
while ( true ) {
4245
4289
expression = parseMemberExpressionRest ( expression ) ;
0 commit comments