File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1883,6 +1883,7 @@ namespace ts {
1883
1883
case SyntaxKind . EnumMember :
1884
1884
case SyntaxKind . TypeAssertionExpression :
1885
1885
case SyntaxKind . AsExpression :
1886
+ case SyntaxKind . NonNullExpression :
1886
1887
case SyntaxKind . ReadonlyKeyword :
1887
1888
// These nodes are TypeScript syntax.
1888
1889
transformFlags = TransformFlags . AssertTypeScript ;
Original file line number Diff line number Diff line change @@ -751,6 +751,8 @@ const _super = (function (geti, seti) {
751
751
return ;
752
752
case SyntaxKind . AsExpression :
753
753
return emitAsExpression ( < AsExpression > node ) ;
754
+ case SyntaxKind . NonNullExpression :
755
+ return emitNonNullExpression ( < NonNullExpression > node ) ;
754
756
755
757
// JSX
756
758
case SyntaxKind . JsxElement :
@@ -1286,6 +1288,11 @@ const _super = (function (geti, seti) {
1286
1288
}
1287
1289
}
1288
1290
1291
+ function emitNonNullExpression ( node : NonNullExpression ) {
1292
+ emitExpression ( node . expression ) ;
1293
+ write ( "!" ) ;
1294
+ }
1295
+
1289
1296
//
1290
1297
// Misc
1291
1298
//
Original file line number Diff line number Diff line change @@ -371,6 +371,10 @@ namespace ts {
371
371
// TypeScript type assertions are removed, but their subtrees are preserved.
372
372
return visitAssertionExpression ( < AssertionExpression > node ) ;
373
373
374
+ case SyntaxKind . NonNullExpression :
375
+ // TypeScript non-null expressions are removed, but their subtrees are preserved.
376
+ return visitNonNullExpression ( < NonNullExpression > node ) ;
377
+
374
378
case SyntaxKind . EnumDeclaration :
375
379
// TypeScript enum declarations do not exist in ES6 and must be rewritten.
376
380
return visitEnumDeclaration ( < EnumDeclaration > node ) ;
@@ -2228,7 +2232,12 @@ namespace ts {
2228
2232
}
2229
2233
2230
2234
function visitAssertionExpression ( node : AssertionExpression ) : Expression {
2231
- const expression = visitNode ( ( < TypeAssertion | AsExpression > node ) . expression , visitor , isExpression ) ;
2235
+ const expression = visitNode ( node . expression , visitor , isExpression ) ;
2236
+ return createPartiallyEmittedExpression ( expression , node ) ;
2237
+ }
2238
+
2239
+ function visitNonNullExpression ( node : NonNullExpression ) : Expression {
2240
+ const expression = visitNode ( node . expression , visitor , isLeftHandSideExpression ) ;
2232
2241
return createPartiallyEmittedExpression ( expression , node ) ;
2233
2242
}
2234
2243
Original file line number Diff line number Diff line change @@ -219,6 +219,9 @@ namespace ts {
219
219
{ name : "expression" , test : isExpression } ,
220
220
{ name : "type" , test : isTypeNode }
221
221
] ,
222
+ [ SyntaxKind . NonNullExpression ] : [
223
+ { name : "expression" , test : isLeftHandSideExpression }
224
+ ] ,
222
225
[ SyntaxKind . TemplateSpan ] : [
223
226
{ name : "expression" , test : isExpression } ,
224
227
{ name : "literal" , test : isTemplateLiteralFragment }
You can’t perform that action at this time.
0 commit comments