Skip to content

Commit e3848b9

Browse files
Fixed bug where function expressions were not getting checked in template expressions.
1 parent 17c8229 commit e3848b9

8 files changed

+35
-33
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8647,6 +8647,8 @@ module ts {
86478647
case SyntaxKind.CallExpression:
86488648
case SyntaxKind.NewExpression:
86498649
case SyntaxKind.TaggedTemplateExpression:
8650+
case SyntaxKind.TemplateExpression:
8651+
case SyntaxKind.TemplateSpan:
86508652
case SyntaxKind.TypeAssertionExpression:
86518653
case SyntaxKind.ParenthesizedExpression:
86528654
case SyntaxKind.TypeOfExpression:
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
2+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,31): error TS2322: Type 'string' is not assignable to type 'number'.
23

34

4-
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ====
5+
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (2 errors) ====
56

67

78
function foo(...rest: any[]) {
89
}
910

1011
foo `${function (x: number) { x = "bad"; } }`;
1112
~~~
12-
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
13+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
14+
~
15+
!!! error TS2322: Type 'string' is not assignable to type 'number'.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(5,31): error TS2322: Type 'string' is not assignable to type 'number'.
2+
3+
4+
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ====
5+
6+
function foo(...rest: any[]) {
7+
}
8+
9+
foo `${function (x: number) { x = "bad"; } }`;
10+
~
11+
!!! error TS2322: Type 'string' is not assignable to type 'number'.

tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(3,27): error TS2322: Type 'string' is not assignable to type 'number'.
2+
3+
4+
==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ====
5+
6+
7+
`${function (x: number) { x = "bad"; } }`;
8+
~
9+
!!! error TS2322: Type 'string' is not assignable to type 'number'.

tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.types

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(2,27): error TS2322: Type 'string' is not assignable to type 'number'.
2+
3+
4+
==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ====
5+
6+
`${function (x: number) { x = "bad"; } }`;
7+
~
8+
!!! error TS2322: Type 'string' is not assignable to type 'number'.

tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.types

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)