Fixed bug where function expressions were not getting checked in template expressions.

This commit is contained in:
Daniel Rosenwasser 2014-12-15 16:45:17 -08:00
parent 17c822966d
commit e3848b98b1
8 changed files with 35 additions and 33 deletions

View file

@ -8647,6 +8647,8 @@ module ts {
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.TemplateExpression:
case SyntaxKind.TemplateSpan:
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.TypeOfExpression:

View file

@ -1,7 +1,8 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,31): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ====
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (2 errors) ====
function foo(...rest: any[]) {
@ -9,4 +10,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFuncti
foo `${function (x: number) { x = "bad"; } }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.

View file

@ -0,0 +1,11 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(5,31): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ====
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.

View file

@ -1,14 +0,0 @@
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts ===
function foo(...rest: any[]) {
>foo : (...rest: any[]) => void
>rest : any[]
}
foo `${function (x: number) { x = "bad"; } }`;
>foo : (...rest: any[]) => void
>function (x: number) { x = "bad"; } : (x: number) => void
>x : number
>x = "bad" : string
>x : number

View file

@ -0,0 +1,9 @@
tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(3,27): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ====
`${function (x: number) { x = "bad"; } }`;
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.

View file

@ -1,9 +0,0 @@
=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts ===
`${function (x: number) { x = "bad"; } }`;
>function (x: number) { x = "bad"; } : (x: number) => void
>x : number
>x = "bad" : string
>x : number

View file

@ -0,0 +1,8 @@
tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(2,27): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ====
`${function (x: number) { x = "bad"; } }`;
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.

View file

@ -1,8 +0,0 @@
=== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts ===
`${function (x: number) { x = "bad"; } }`;
>function (x: number) { x = "bad"; } : (x: number) => void
>x : number
>x = "bad" : string
>x : number