@@ -207,6 +207,8 @@ namespace ts {
207207 visitNode ( cbNode , ( < AsExpression > node ) . type ) ;
208208 case SyntaxKind . NonNullExpression :
209209 return visitNode ( cbNode , ( < NonNullExpression > node ) . expression ) ;
210+ case SyntaxKind . NonNullTypeNode :
211+ return visitNode ( cbNode , ( < NonNullTypeNode > node ) . type ) ;
210212 case SyntaxKind . MetaProperty :
211213 return visitNode ( cbNode , ( < MetaProperty > node ) . name ) ;
212214 case SyntaxKind . ConditionalExpression :
@@ -396,8 +398,6 @@ namespace ts {
396398
397399 case SyntaxKind . JSDocTypeExpression :
398400 return visitNode ( cbNode , ( < JSDocTypeExpression > node ) . type ) ;
399- case SyntaxKind . JSDocNonNullableType :
400- return visitNode ( cbNode , ( < JSDocNonNullableType > node ) . type ) ;
401401 case SyntaxKind . JSDocNullableType :
402402 return visitNode ( cbNode , ( < JSDocNullableType > node ) . type ) ;
403403 case SyntaxKind . JSDocOptionalType :
@@ -2175,8 +2175,8 @@ namespace ts {
21752175 return finishNode ( parameter ) ;
21762176 }
21772177
2178- function parseJSDocNodeWithType ( kind : SyntaxKind . JSDocVariadicType | SyntaxKind . JSDocNonNullableType ) : TypeNode {
2179- const result = createNode ( kind ) as JSDocVariadicType | JSDocNonNullableType ;
2178+ function parseJSDocNodeWithType ( kind : SyntaxKind . JSDocVariadicType ) : TypeNode {
2179+ const result = createNode ( kind ) as JSDocVariadicType ;
21802180 nextToken ( ) ;
21812181 result . type = parseType ( ) ;
21822182 return finishNode ( result ) ;
@@ -2662,8 +2662,6 @@ namespace ts {
26622662 return parseJSDocFunctionType ( ) ;
26632663 case SyntaxKind . DotDotDotToken :
26642664 return parseJSDocNodeWithType ( SyntaxKind . JSDocVariadicType ) ;
2665- case SyntaxKind . ExclamationToken :
2666- return parseJSDocNodeWithType ( SyntaxKind . JSDocNonNullableType ) ;
26672665 case SyntaxKind . StringLiteral :
26682666 case SyntaxKind . NumericLiteral :
26692667 case SyntaxKind . TrueKeyword :
@@ -2744,7 +2742,7 @@ namespace ts {
27442742 if ( ! kind ) return type ;
27452743 nextToken ( ) ;
27462744
2747- const postfix = createNode ( kind , type . pos ) as JSDocOptionalType | JSDocNonNullableType | JSDocNullableType ;
2745+ const postfix = createNode ( kind , type . pos ) as JSDocOptionalType | JSDocNullableType ;
27482746 postfix . type = type ;
27492747 return finishNode ( postfix ) ;
27502748
@@ -2753,8 +2751,6 @@ namespace ts {
27532751 case SyntaxKind . EqualsToken :
27542752 // only parse postfix = inside jsdoc, because it's ambiguous elsewhere
27552753 return contextFlags & NodeFlags . JSDoc ? SyntaxKind . JSDocOptionalType : undefined ;
2756- case SyntaxKind . ExclamationToken :
2757- return SyntaxKind . JSDocNonNullableType ;
27582754 case SyntaxKind . QuestionToken :
27592755 return SyntaxKind . JSDocNullableType ;
27602756 }
@@ -2794,7 +2790,36 @@ namespace ts {
27942790 case SyntaxKind . KeyOfKeyword :
27952791 return parseTypeOperator ( SyntaxKind . KeyOfKeyword ) ;
27962792 }
2797- return parseArrayTypeOrHigher ( ) ;
2793+ const type = parseArrayTypeOrHigher ( ) ;
2794+ return parsePostfixTypeOperatorOrHigher ( type ) ;
2795+ }
2796+
2797+ function parsePostfixTypeOperator ( type : TypeNode ) { // , parseKind: SyntaxKind, nodeKind: SyntaxKind
2798+ const node = < NonNullTypeNode > createNode ( SyntaxKind . NonNullTypeNode ) ;
2799+ // const node = <NonNullTypeNode>createNode(nodeKind);
2800+ // parseExpected(operator);
2801+ parseExpected ( SyntaxKind . ExclamationToken ) ;
2802+ // parseExpected(parseKind);
2803+ // node.operator = operator;
2804+ node . type = type ;
2805+ const finished = finishNode ( node ) ;
2806+ finished . pos = type . pos ;
2807+ // finished.end = type.end + 1;
2808+ return finished ;
2809+ }
2810+
2811+ function parsePostfixTypeOperatorOrHigher ( type : TypeNode ) : TypeNode {
2812+ let postfixed : TypeNode ;
2813+ switch ( token ( ) ) {
2814+ case SyntaxKind . ExclamationToken :
2815+ postfixed = parsePostfixTypeOperator ( type ) ; // , SyntaxKind.ExclamationToken, SyntaxKind.NonNullTypeNode
2816+ }
2817+ if ( postfixed ) {
2818+ return parsePostfixTypeOperatorOrHigher ( postfixed ) ;
2819+ }
2820+ else {
2821+ return type ;
2822+ }
27982823 }
27992824
28002825 function parseUnionOrIntersectionType ( kind : SyntaxKind . UnionType | SyntaxKind . IntersectionType , parseConstituentType : ( ) => TypeNode , operator : SyntaxKind . BarToken | SyntaxKind . AmpersandToken ) : TypeNode {
0 commit comments