diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4a352c30a35..81f35812c3a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -491,6 +491,7 @@ module ts { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.TemplateExpression: + case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.OmittedExpression: return true; case SyntaxKind.QualifiedName: @@ -503,7 +504,6 @@ module ts { // fall through case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: - case SyntaxKind.NoSubstitutionTemplateLiteral: var parent = node.parent; switch (parent.kind) { case SyntaxKind.VariableDeclaration: @@ -532,6 +532,8 @@ module ts { (parent).expression === node; case SyntaxKind.TypeAssertion: return node === (parent).operand; + case SyntaxKind.TemplateSpan: + return node === (parent).expression; default: if (isExpression(parent)) { return true; diff --git a/tests/baselines/reference/templateStringInArrowFunction.types b/tests/baselines/reference/templateStringInArrowFunction.types index e17f4d6d2ea..2c157815897 100644 --- a/tests/baselines/reference/templateStringInArrowFunction.types +++ b/tests/baselines/reference/templateStringInArrowFunction.types @@ -3,5 +3,5 @@ var x = x => `abc${ x }def`; >x : (x: any) => string >x => `abc${ x }def` : (x: any) => string >x : any ->x : unknown +>x : any diff --git a/tests/baselines/reference/templateStringInArrowFunctionES6.types b/tests/baselines/reference/templateStringInArrowFunctionES6.types index 38fca60e647..5f66590d490 100644 --- a/tests/baselines/reference/templateStringInArrowFunctionES6.types +++ b/tests/baselines/reference/templateStringInArrowFunctionES6.types @@ -3,5 +3,5 @@ var x = x => `abc${ x }def`; >x : (x: any) => string >x => `abc${ x }def` : (x: any) => string >x : any ->x : unknown +>x : any diff --git a/tests/cases/fourslash/findAllRefsInsideTemplates1.ts b/tests/cases/fourslash/findAllRefsInsideTemplates1.ts new file mode 100644 index 00000000000..e4501219265 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsInsideTemplates1.ts @@ -0,0 +1,12 @@ +/// + +////var [|x|] = 10; +////var y = `${ [|x|] } ${ [|x|] }` + +test.ranges().forEach(targetRange => { + goTo.position(targetRange.start); + + test.ranges().forEach(range => { + verify.referencesAtPositionContains(range); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsInsideTemplates2.ts b/tests/cases/fourslash/findAllRefsInsideTemplates2.ts new file mode 100644 index 00000000000..cafddd4f45b --- /dev/null +++ b/tests/cases/fourslash/findAllRefsInsideTemplates2.ts @@ -0,0 +1,12 @@ +/// + +////function [|f|](...rest: any[]) { } +////[|f|] `${ [|f|] } ${ [|f|] }` + +test.ranges().forEach(targetRange => { + goTo.position(targetRange.start); + + test.ranges().forEach(range => { + verify.referencesAtPositionContains(range); + } +} \ No newline at end of file