File tree Expand file tree Collapse file tree 5 files changed +24
-3
lines changed Expand file tree Collapse file tree 5 files changed +24
-3
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 @@ -372,6 +372,10 @@ namespace ts {
372
372
// TypeScript type assertions are removed, but their subtrees are preserved.
373
373
return visitAssertionExpression ( < AssertionExpression > node ) ;
374
374
375
+ case SyntaxKind . NonNullExpression :
376
+ // TypeScript non-null expressions are removed, but their subtrees are preserved.
377
+ return visitNonNullExpression ( < NonNullExpression > node ) ;
378
+
375
379
case SyntaxKind . EnumDeclaration :
376
380
// TypeScript enum declarations do not exist in ES6 and must be rewritten.
377
381
return visitEnumDeclaration ( < EnumDeclaration > node ) ;
@@ -2233,7 +2237,12 @@ namespace ts {
2233
2237
}
2234
2238
2235
2239
function visitAssertionExpression ( node : AssertionExpression ) : Expression {
2236
- const expression = visitNode ( ( < TypeAssertion | AsExpression > node ) . expression , visitor , isExpression ) ;
2240
+ const expression = visitNode ( node . expression , visitor , isExpression ) ;
2241
+ return createPartiallyEmittedExpression ( expression , node ) ;
2242
+ }
2243
+
2244
+ function visitNonNullExpression ( node : NonNullExpression ) : Expression {
2245
+ const expression = visitNode ( node . expression , visitor , isLeftHandSideExpression ) ;
2237
2246
return createPartiallyEmittedExpression ( expression , node ) ;
2238
2247
}
2239
2248
Original file line number Diff line number Diff line change @@ -509,7 +509,7 @@ namespace ts {
509
509
const { line : startLine } = getLineAndCharacterOfPosition ( sourceFile , node . body . pos ) ;
510
510
const { line : endLine } = getLineAndCharacterOfPosition ( sourceFile , node . body . end ) ;
511
511
if ( startLine < endLine ) {
512
- // The arrow function spans multiple lines,
512
+ // The arrow function spans multiple lines,
513
513
// make the error span be the first line, inclusive.
514
514
return createTextSpan ( pos , getEndLinePosition ( startLine , sourceFile ) - pos + 1 ) ;
515
515
}
@@ -3462,7 +3462,8 @@ namespace ts {
3462
3462
|| kind === SyntaxKind . NullKeyword
3463
3463
|| kind === SyntaxKind . ThisKeyword
3464
3464
|| kind === SyntaxKind . TrueKeyword
3465
- || kind === SyntaxKind . SuperKeyword ;
3465
+ || kind === SyntaxKind . SuperKeyword
3466
+ || kind === SyntaxKind . NonNullExpression ;
3466
3467
}
3467
3468
3468
3469
export function isLeftHandSideExpression ( node : Node ) : node is LeftHandSideExpression {
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