8000 Merge pull request #8208 from Microsoft/transforms-fixDebugFailure · sweshgit/TypeScript@2940a3f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2940a3f

Browse files
committed
Merge pull request microsoft#8208 from Microsoft/transforms-fixDebugFailure
[Transforms] Fix debug failure caused by merge.
2 parents e645de3 + de33689 commit 2940a3f

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,7 @@ namespace ts {
18831883
case SyntaxKind.EnumMember:
18841884
case SyntaxKind.TypeAssertionExpression:
18851885
case SyntaxKind.AsExpression:
1886+
case SyntaxKind.NonNullExpression:
18861887
case SyntaxKind.ReadonlyKeyword:
18871888
// These nodes are TypeScript syntax.
18881889
transformFlags = TransformFlags.AssertTypeScript;

src/compiler/printer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ const _super = (function (geti, seti) {
751751
return;
752752
case SyntaxKind.AsExpression:
753753
return emitAsExpression(<AsExpression>node);
754+
case SyntaxKind.NonNullExpression:
755+
return emitNonNullExpression(<NonNullExpression>node);
754756

755757
// JSX
756758
case SyntaxKind.JsxElement:
@@ -1286,6 +1288,11 @@ const _super = (function (geti, seti) {
12861288
}
12871289
}
12881290

1291+
function emitNonNullExpression(node: NonNullExpression) {
1292+
emitExpression(node.expression);
1293+
write("!");
1294+
}
1295+
12891296
//
12901297
// Misc
12911298
//

src/compiler/transformers/ts.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ namespace ts {
372372
// TypeScript type assertions are removed, but their subtrees are preserved.
373373
return visitAssertionExpression(<AssertionExpression>node);
374374

375+
case SyntaxKind.NonNullExpression:
376+
// TypeScript non-null expressions are removed, but their subtrees are preserved.
377+
return visitNonNullExpression(<NonNullExpression>node);
378+
375379
case SyntaxKind.EnumDeclaration:
376380
// TypeScript enum declarations do not exist in ES6 and must be rewritten.
377381
return visitEnumDeclaration(<EnumDeclaration>node);
@@ -2233,7 +2237,12 @@ namespace ts {
22332237
}
22342238

22352239
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);
22372246
return createPartiallyEmittedExpression(expression, node);
22382247
}
22392248

src/compiler/utilities.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ namespace ts {
509509
const { line: startLine } = getLineAndCharacterOfPosition(sourceFile, node.body.pos);
510510
const { line: endLine } = getLineAndCharacterOfPosition(sourceFile, node.body.end);
511511
if (startLine < endLine) {
512-
// The arrow function spans multiple lines,
512+
// The arrow function spans multiple lines,
513513
// make the error span be the first line, inclusive.
514514
return createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
515515
}
@@ -3462,7 +3462,8 @@ namespace ts {
34623462
|| kind === SyntaxKind.NullKeyword
34633463
|| kind === SyntaxKind.ThisKeyword
34643464
|| kind === SyntaxKind.TrueKeyword
3465-
|| kind === SyntaxKind.SuperKeyword;
3465+
|| kind === SyntaxKind.SuperKeyword
3466+
|| kind === SyntaxKind.NonNullExpression;
34663467
}
34673468

34683469
export function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression {

src/compiler/visitor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ namespace ts {
219219
{ name: "expression", test: isExpression },
220220
{ name: "type", test: isTypeNode }
221221
],
222+
[SyntaxKind.NonNullExpression]: [
223+
{ name: "expression", test: isLeftHandSideExpression }
224+
],
222225
[SyntaxKind.TemplateSpan]: [
223226
{ name: "expression", test: isExpression },
224227
{ name: "literal", test: isTemplateLiteralFragment }

0 commit comments

Comments
 (0)
0