@@ -170,6 +170,10 @@ namespace ts {
170170 case SyntaxKind . ElementAccessExpression :
171171 return visitNode ( cbNode , ( < ElementAccessExpression > node ) . expression ) ||
172172 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 ) ;
173177 case SyntaxKind . CallExpression :
174178 case SyntaxKind . NewExpression :
175179 return visitNode ( cbNode , ( < CallExpression > node ) . expression ) ||
@@ -2738,8 +2742,8 @@ namespace ts {
27382742 return token ( ) === SyntaxKind . CloseParenToken || isStartOfParameter ( ) || isStartOfType ( ) ;
27392743 }
27402744
2741- function parseJSDocPostfixTypeOrHigher ( ) : TypeNode {
2742- const type = parseNonArrayType ( ) ;
2745+ function parseJSDocPostfixTypeOrHigher ( typeNode ?: TypeNode ) : TypeNode {
2746+ const type = typeNode || parseNonArrayType ( ) ;
27432747 const kind = getKind ( token ( ) ) ;
27442748 if ( ! kind ) return type ;
27452749 nextToken ( ) ;
@@ -2761,8 +2765,8 @@ namespace ts {
27612765 }
27622766 }
27632767
2764- function parseArrayTypeOrHigher ( ) : TypeNode {
2765- let type = parseJSDocPostfixTypeOrHigher ( ) ;
2768+ function parseArrayTypeOrHigher ( typeNode ?: TypeNode ) : TypeNode {
2769+ let type = parseJSDocPostfixTypeOrHigher ( typeNode ) ;
27662770 while ( ! scanner . hasPrecedingLineBreak ( ) && parseOptional ( SyntaxKind . OpenBracketToken ) ) {
27672771 if ( isStartOfType ( ) ) {
27682772 const node = < IndexedAccessTypeNode > createNode ( SyntaxKind . IndexedAccessType , type . pos ) ;
@@ -2794,7 +2798,7 @@ namespace ts {
27942798 case SyntaxKind . KeyOfKeyword :
27952799 return parseTypeOperator ( SyntaxKind . KeyOfKeyword ) ;
27962800 }
2797- return parseArrayTypeOrHigher ( ) ;
2801+ return parseTypeCallRest ( ) ;
27982802 }
27992803
28002804 function parseUnionOrIntersectionType ( kind : SyntaxKind . UnionType | SyntaxKind . IntersectionType , parseConstituentType : ( ) => TypeNode , operator : SyntaxKind . BarToken | SyntaxKind . AmpersandToken ) : TypeNode {
@@ -4240,6 +4244,46 @@ namespace ts {
42404244 }
42414245 }
42424246
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+
42434287 function parseCallExpressionRest ( expression : LeftHandSideExpression ) : LeftHandSideExpression {
42444288 while ( true ) {
42454289 expression = parseMemberExpressionRest ( expression ) ;
0 commit comments