diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5da1952ab2731..20a7f4ca46bef 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -490,6 +490,7 @@ module ts { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.TemplateExpression: + case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.OmittedExpression: return true; case SyntaxKind.QualifiedName: @@ -502,7 +503,6 @@ module ts { // fall through case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: - case SyntaxKind.NoSubstitutionTemplateLiteral: var parent = node.parent; switch (parent.kind) { case SyntaxKind.VariableDeclaration: @@ -531,6 +531,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 e17f4d6d2eaf4..2c1578158975f 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 38fca60e64758..5f66590d4905b 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 0000000000000..e45012192650d --- /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 0000000000000..cafddd4f45b67 --- /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