@@ -207,6 +207,8 @@ namespace ts {
207
207
visitNode ( cbNode , ( < AsExpression > node ) . type ) ;
208
208
case SyntaxKind . NonNullExpression :
209
209
return visitNode ( cbNode , ( < NonNullExpression > node ) . expression ) ;
210
+ case SyntaxKind . NonNullTypeNode :
211
+ return visitNode ( cbNode , ( < NonNullTypeNode > node ) . type ) ;
210
212
case SyntaxKind . MetaProperty :
211
213
return visitNode ( cbNode , ( < MetaProperty > node ) . name ) ;
212
214
case SyntaxKind . ConditionalExpression :
@@ -396,8 +398,6 @@ namespace ts {
396
398
397
399
case SyntaxKind . JSDocTypeExpression :
398
400
return visitNode ( cbNode , ( < JSDocTypeExpression > node ) . type ) ;
399
- case SyntaxKind . JSDocNonNullableType :
400
- return visitNode ( cbNode , ( < JSDocNonNullableType > node ) . type ) ;
401
401
case SyntaxKind . JSDocNullableType :
402
402
return visitNode ( cbNode , ( < JSDocNullableType > node ) . type ) ;
403
403
case SyntaxKind . JSDocOptionalType :
@@ -2175,8 +2175,8 @@ namespace ts {
2175
2175
return finishNode ( parameter ) ;
2176
2176
}
2177
2177
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 ;
2180
2180
nextToken ( ) ;
2181
2181
result . type = parseType ( ) ;
2182
2182
return finishNode ( result ) ;
@@ -2662,8 +2662,6 @@ namespace ts {
2662
2662
return parseJSDocFunctionType ( ) ;
2663
2663
case SyntaxKind . DotDotDotToken :
2664
2664
return parseJSDocNodeWithType ( SyntaxKind . JSDocVariadicType ) ;
2665
- case SyntaxKind . ExclamationToken :
2666
- return parseJSDocNodeWithType ( SyntaxKind . JSDocNonNullableType ) ;
2667
2665
case SyntaxKind . StringLiteral :
2668
2666
case SyntaxKind . NumericLiteral :
2669
2667
case SyntaxKind . TrueKeyword :
@@ -2744,7 +2742,7 @@ namespace ts {
2744
2742
if ( ! kind ) return type ;
2745
2743
nextToken ( ) ;
2746
2744
2747
- const postfix = createNode ( kind , type . pos ) as JSDocOptionalType | JSDocNonNullableType | JSDocNullableType ;
2745
+ const postfix = createNode ( kind , type . pos ) as JSDocOptionalType | JSDocNullableType ;
2748
2746
postfix . type = type ;
2749
2747
return finishNode ( postfix ) ;
2750
2748
@@ -2753,8 +2751,6 @@ namespace ts {
2753
2751
case SyntaxKind . EqualsToken :
2754
2752
// only parse postfix = inside jsdoc, because it's ambiguous elsewhere
2755
2753
return contextFlags & NodeFlags . JSDoc ? SyntaxKind . JSDocOptionalType : undefined ;
2756
- case SyntaxKind . ExclamationToken :
2757
- return SyntaxKind . JSDocNonNullableType ;
2758
2754
case SyntaxKind . QuestionToken :
2759
2755
return SyntaxKind . JSDocNullableType ;
2760
2756
}
@@ -2794,7 +2790,36 @@ namespace ts {
2794
2790
case SyntaxKind . KeyOfKeyword :
2795
2791
return parseTypeOperator ( SyntaxKind . KeyOfKeyword ) ;
2796
2792
}
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
+ }
2798
2823
}
2799
2824
2800
2825
function parseUnionOrIntersectionType ( kind : SyntaxKind . UnionType | SyntaxKind . IntersectionType , parseConstituentType : ( ) => TypeNode , operator : SyntaxKind . BarToken | SyntaxKind . AmpersandToken ) : TypeNode {
0 commit comments