Skip to content

Commit dbcb6dc

Browse files
Corrected isExpression for templates.
Fixes #1046.
1 parent 356622c commit dbcb6dc

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/compiler/parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ module ts {
490490
case SyntaxKind.BinaryExpression:
491491
case SyntaxKind.ConditionalExpression:
492492
case SyntaxKind.TemplateExpression:
493+
case SyntaxKind.NoSubstitutionTemplateLiteral:
493494
case SyntaxKind.OmittedExpression:
494495
return true;
495496
case SyntaxKind.QualifiedName:
@@ -502,7 +503,6 @@ module ts {
502503
// fall through
503504
case SyntaxKind.NumericLiteral:
504505
case SyntaxKind.StringLiteral:
505-
case SyntaxKind.NoSubstitutionTemplateLiteral:
506506
var parent = node.parent;
507507
switch (parent.kind) {
508508
case SyntaxKind.VariableDeclaration:
@@ -531,6 +531,8 @@ module ts {
531531
(<ForInStatement>parent).expression === node;
532532
case SyntaxKind.TypeAssertion:
533533
return node === (<TypeAssertion>parent).operand;
534+
case SyntaxKind.TemplateSpan:
535+
return node === (<TemplateSpan>parent).expression;
534536
default:
535537
if (isExpression(parent)) {
536538
return true;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////var [|x|] = 10;
4+
////var y = `${ [|x|] } ${ [|x|] }`
5+
6+
test.ranges().forEach(targetRange => {
7+
goTo.position(targetRange.start);
8+
9+
test.ranges().forEach(range => {
10+
verify.referencesAtPositionContains(range);
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////function [|f|](...rest: any[]) { }
4+
////[|f|] `${ [|f|] } ${ [|f|] }`
5+
6+
test.ranges().forEach(targetRange => {
7+
goTo.position(targetRange.start);
8+
9+
test.ranges().forEach(range => {
10+
verify.referencesAtPositionContains(range);
11+
}
12+
}

0 commit comments

Comments
 (0)