Skip to content

Commit d99023e

Browse files
Merge pull request #1094 from Microsoft/findAllRefsInTemplates
Corrected isExpression for templates.
2 parents 0bacf8f + c9919bb commit d99023e

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

src/compiler/parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ module ts {
491491
case SyntaxKind.BinaryExpression:
492492
case SyntaxKind.ConditionalExpression:
493493
case SyntaxKind.TemplateExpression:
494+
case SyntaxKind.NoSubstitutionTemplateLiteral:
494495
case SyntaxKind.OmittedExpression:
495496
return true;
496497
case SyntaxKind.QualifiedName:
@@ -503,7 +504,6 @@ module ts {
503504
// fall through
504505
case SyntaxKind.NumericLiteral:
505506
case SyntaxKind.StringLiteral:
506-
case SyntaxKind.NoSubstitutionTemplateLiteral:
507507
var parent = node.parent;
508508
switch (parent.kind) {
509509
case SyntaxKind.VariableDeclaration:
@@ -532,6 +532,8 @@ module ts {
532532
(<ForInStatement>parent).expression === node;
533533
case SyntaxKind.TypeAssertion:
534534
return node === (<TypeAssertion>parent).operand;
535+
case SyntaxKind.TemplateSpan:
536+
return node === (<TemplateSpan>parent).expression;
535537
default:
536538
if (isExpression(parent)) {
537539
return true;

tests/baselines/reference/templateStringInArrowFunction.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ var x = x => `abc${ x }def`;
33
>x : (x: any) => string
44
>x => `abc${ x }def` : (x: any) => string
55
>x : any
6-
>x : unknown
6+
>x : any
77

tests/baselines/reference/templateStringInArrowFunctionES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ var x = x => `abc${ x }def`;
33
>x : (x: any) => string
44
>x => `abc${ x }def` : (x: any) => string
55
>x : any
6-
>x : unknown
6+
>x : any
77

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)