Fixed issue where template expression in call expressions would emit with unnecessary parentheses.

Fixes #1205.
This commit is contained in:
Daniel Rosenwasser
2014-11-19 17:04:34 -08:00
parent 8b35beaa1c
commit f51a42c6de
19 changed files with 117 additions and 24 deletions

View File

@@ -1,16 +1,16 @@
tests/cases/compiler/amdModuleName2.ts(2,1): error TS2458: An AMD module cannot have multiple name assignments.
==== tests/cases/compiler/amdModuleName2.ts (1 errors) ====
///<amd-module name='FirstModuleName'/>
///<amd-module name='SecondModuleName'/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2458: An AMD module cannot have multiple name assignments.
class Foo {
x: number;
constructor() {
this.x = 5;
}
}
export = Foo;
tests/cases/compiler/amdModuleName2.ts(2,1): error TS2458: An AMD module cannot have multiple name assignments.
==== tests/cases/compiler/amdModuleName2.ts (1 errors) ====
///<amd-module name='FirstModuleName'/>
///<amd-module name='SecondModuleName'/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2458: An AMD module cannot have multiple name assignments.
class Foo {
x: number;
constructor() {
this.x = 5;
}
}
export = Foo;

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/es6/templates/templateStringInCallExpression.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
==== tests/cases/conformance/es6/templates/templateStringInCallExpression.ts (1 errors) ====
`abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.

View File

@@ -0,0 +1,5 @@
//// [templateStringInCallExpression.ts]
`abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
//// [templateStringInCallExpression.js]
("abc" + 0 + "abc")("hello " + 0 + " world", " ", "1" + 2 + "3");

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/es6/templates/templateStringInCallExpressionES6.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
==== tests/cases/conformance/es6/templates/templateStringInCallExpressionES6.ts (1 errors) ====
`abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.

View File

@@ -0,0 +1,5 @@
//// [templateStringInCallExpressionES6.ts]
`abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
//// [templateStringInCallExpressionES6.js]
`abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/es6/templates/templateStringInNewExpression.ts(1,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
==== tests/cases/conformance/es6/templates/templateStringInNewExpression.ts (1 errors) ====
new `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.

View File

@@ -0,0 +1,5 @@
//// [templateStringInNewExpression.ts]
new `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
//// [templateStringInNewExpression.js]
new ("abc" + 0 + "abc")("hello " + 0 + " world", " ", "1" + 2 + "3");

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/es6/templates/templateStringInNewExpressionES6.ts(1,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
==== tests/cases/conformance/es6/templates/templateStringInNewExpressionES6.ts (1 errors) ====
new `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.

View File

@@ -0,0 +1,5 @@
//// [templateStringInNewExpressionES6.ts]
new `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);
//// [templateStringInNewExpressionES6.js]
new `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);

View File

@@ -0,0 +1,10 @@
tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts (2 errors) ====
`I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/es6/templates/templateStringInTaggedTemplateES6.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplateES6.ts (1 errors) ====
`I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.

View File

@@ -0,0 +1,5 @@
//// [templateStringInTaggedTemplateES6.ts]
`I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION`
//// [templateStringInTaggedTemplateES6.js]
`I AM THE ${`${`TAG`} `} PORTION` `I ${"AM"} THE TEMPLATE PORTION`;

View File

@@ -0,0 +1 @@
`abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);

View File

@@ -0,0 +1,2 @@
// @target: ES6
`abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);

View File

@@ -0,0 +1 @@
new `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);

View File

@@ -0,0 +1,2 @@
// @target: ES6
new `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`);

View File

@@ -0,0 +1 @@
`I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION`

View File

@@ -0,0 +1,2 @@
// @target: ES6
`I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION`