mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Added tests for erroneous function expressions in both tagged/untagged template expressions.
This commit is contained in:
parent
0263d60071
commit
17c822966d
@ -0,0 +1,12 @@
|
||||
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 (1 errors) ====
|
||||
|
||||
|
||||
function foo(...rest: any[]) {
|
||||
}
|
||||
|
||||
foo `${function (x: number) { x = "bad"; } }`;
|
||||
~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
@ -0,0 +1,17 @@
|
||||
//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts]
|
||||
|
||||
function foo(...rest: any[]) {
|
||||
}
|
||||
|
||||
foo `${function (x: number) { x = "bad"; } }`;
|
||||
|
||||
//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js]
|
||||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo `${function (x) {
|
||||
x = "bad";
|
||||
}}`;
|
||||
@ -0,0 +1,14 @@
|
||||
=== 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
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts]
|
||||
|
||||
|
||||
`${function (x: number) { x = "bad"; } }`;
|
||||
|
||||
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js]
|
||||
"" + function (x) {
|
||||
x = "bad";
|
||||
};
|
||||
@ -0,0 +1,9 @@
|
||||
=== 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
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts]
|
||||
|
||||
`${function (x: number) { x = "bad"; } }`;
|
||||
|
||||
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js]
|
||||
`${function (x) {
|
||||
x = "bad";
|
||||
}}`;
|
||||
@ -0,0 +1,8 @@
|
||||
=== 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
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
function foo(...rest: any[]) {
|
||||
}
|
||||
|
||||
foo `${function (x: number) { x = "bad"; } }`;
|
||||
@ -0,0 +1,6 @@
|
||||
//@target: es6
|
||||
|
||||
function foo(...rest: any[]) {
|
||||
}
|
||||
|
||||
foo `${function (x: number) { x = "bad"; } }`;
|
||||
@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
`${function (x: number) { x = "bad"; } }`;
|
||||
@ -0,0 +1,3 @@
|
||||
//@target: es6
|
||||
|
||||
`${function (x: number) { x = "bad"; } }`;
|
||||
Loading…
x
Reference in New Issue
Block a user