Merge pull request #1589 from ivogabe/taggedTemplates

Tagged templates ES3 & 5
This commit is contained in:
Daniel Rosenwasser 2015-02-26 10:29:40 -08:00
commit a77d39bc2c
64 changed files with 695 additions and 531 deletions

View file

@ -377,6 +377,7 @@ module ts {
function bind(node: Node) {
node.parent = parent;
switch (node.kind) {
case SyntaxKind.TypeParameter:
bindDeclaration(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false);

View file

@ -6759,11 +6759,6 @@ module ts {
}
function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type {
// Grammar checking
if (languageVersion < ScriptTarget.ES6) {
grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher);
}
return getReturnTypeOfSignature(getResolvedSignature(node));
}

View file

@ -117,7 +117,6 @@ module ts {
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" },
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." },
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." },
Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." },
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },

View file

@ -459,10 +459,6 @@
"category": "Error",
"code": 1157
},
"Tagged templates are only available when targeting ECMAScript 6 and higher.": {
"category": "Error",
"code": 1159
},
"Unterminated template literal.": {
"category": "Error",
"code": 1160

View file

@ -2072,7 +2072,7 @@ module ts {
}
}
function emitParenthesized(node: Node, parenthesized: boolean) {
function emitParenthesizedIf(node: Node, parenthesized: boolean) {
if (parenthesized) {
write("(");
}
@ -2205,6 +2205,72 @@ module ts {
function getTemplateLiteralAsStringLiteral(node: LiteralExpression): string {
return '"' + escapeString(node.text) + '"';
}
function emitDownlevelRawTemplateLiteral(node: LiteralExpression) {
// Find original source text, since we need to emit the raw strings of the tagged template.
// The raw strings contain the (escaped) strings of what the user wrote.
// Examples: `\n` is converted to "\\n", a template string with a newline to "\n".
var text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
// text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
// thus we need to remove those characters.
// First template piece starts with "`", others with "}"
// Last template piece ends with "`", others with "${"
var isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail;
text = text.substring(1, text.length - (isLast ? 1 : 2));
// Newline normalization:
// ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's
// <CR><LF> and <CR> LineTerminatorSequences are normalized to <LF> for both TV and TRV.
text = text.replace(/\r\n?/g, "\n");
text = escapeString(text);
write('"' + text + '"');
}
function emitDownlevelTaggedTemplateArray(node: TaggedTemplateExpression, literalEmitter: (literal: LiteralExpression) => void) {
write("[");
if (node.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral) {
literalEmitter(<LiteralExpression>node.template);
}
else {
literalEmitter((<TemplateExpression>node.template).head);
forEach((<TemplateExpression>node.template).templateSpans, (child) => {
write(", ");
literalEmitter(child.literal);
});
}
write("]");
}
function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) {
var tempVariable = createAndRecordTempVariable(node);
write("(");
emit(tempVariable);
write(" = ");
emitDownlevelTaggedTemplateArray(node, emit);
write(", ");
emit(tempVariable);
write(".raw = ");
emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral);
write(", ");
emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag));
write("(");
emit(tempVariable);
// Now we emit the expressions
if (node.template.kind === SyntaxKind.TemplateExpression) {
forEach((<TemplateExpression>node.template).templateSpans, templateSpan => {
write(", ");
var needsParens = templateSpan.expression.kind === SyntaxKind.BinaryExpression
&& (<BinaryExpression>templateSpan.expression).operatorToken.kind === SyntaxKind.CommaToken;
emitParenthesizedIf(templateSpan.expression, needsParens);
});
}
write("))");
}
function emitTemplateExpression(node: TemplateExpression): void {
// In ES6 mode and above, we can simply emit each portion of a template in order, but in
@ -2249,7 +2315,8 @@ module ts {
write(" + ");
}
emitParenthesized(templateSpan.expression, needsParens);
emitParenthesizedIf(templateSpan.expression, needsParens);
// Only emit if the literal is non-empty.
// The binary '+' operator is left-associative, so the first string concatenation
// with the head will force the result up to this point to be a string.
@ -2479,7 +2546,7 @@ module ts {
emit((<SpreadElementExpression>node).expression);
}
function needsParenthesisForPropertyAccess(node: Expression) {
function needsParenthesisForPropertyAccessOrInvocation(node: Expression) {
switch (node.kind) {
case SyntaxKind.Identifier:
case SyntaxKind.ArrayLiteralExpression:
@ -2509,7 +2576,7 @@ module ts {
var e = elements[pos];
if (e.kind === SyntaxKind.SpreadElementExpression) {
e = (<SpreadElementExpression>e).expression;
emitParenthesized(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccess(e));
emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e));
pos++;
}
else {
@ -2985,9 +3052,14 @@ module ts {
}
function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void {
emit(node.tag);
write(" ");
emit(node.template);
if (compilerOptions.target >= ScriptTarget.ES6) {
emit(node.tag);
write(" ");
emit(node.template);
}
else {
emitDownlevelTaggedTemplate(node);
}
}
function emitParenExpression(node: ParenthesizedExpression) {
@ -3157,7 +3229,7 @@ module ts {
}
function emitExpressionStatement(node: ExpressionStatement) {
emitParenthesized(node.expression, /*parenthesized*/ node.expression.kind === SyntaxKind.ArrowFunction);
emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === SyntaxKind.ArrowFunction);
write(";");
}

View file

@ -0,0 +1,15 @@
//// [taggedTemplateStringsHexadecimalEscapes.ts]
function f(...args: any[]) {
}
f `\x0D${ "Interrupted CRLF" }\x0A`;
//// [taggedTemplateStringsHexadecimalEscapes.js]
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
(_a = ["\r", "\n"], _a.raw = ["\\x0D", "\\x0A"], f(_a, "Interrupted CRLF"));
var _a;

View file

@ -0,0 +1,9 @@
=== tests/cases/compiler/taggedTemplateStringsHexadecimalEscapes.ts ===
function f(...args: any[]) {
>f : (...args: any[]) => void
>args : any[]
}
f `\x0D${ "Interrupted CRLF" }\x0A`;
>f : (...args: any[]) => void

View file

@ -0,0 +1,10 @@
//// [taggedTemplateStringsHexadecimalEscapesES6.ts]
function f(...args: any[]) {
}
f `\x0D${ "Interrupted CRLF" }\x0A`;
//// [taggedTemplateStringsHexadecimalEscapesES6.js]
function f(...args) {
}
f `\x0D${"Interrupted CRLF"}\x0A`;

View file

@ -0,0 +1,9 @@
=== tests/cases/compiler/taggedTemplateStringsHexadecimalEscapesES6.ts ===
function f(...args: any[]) {
>f : (...args: any[]) => void
>args : any[]
}
f `\x0D${ "Interrupted CRLF" }\x0A`;
>f : (...args: any[]) => void

View file

@ -1,13 +0,0 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts(7,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts (1 errors) ====
function f(...x: any[]) {
}
f `0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.

View file

@ -14,4 +14,5 @@ function f() {
x[_i - 0] = arguments[_i];
}
}
f "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n";
(_a = ["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"], _a.raw = ["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"], f(_a));
var _a;

View file

@ -0,0 +1,12 @@
=== tests/cases/conformance/es6/templates/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.ts ===
function f(...x: any[]) {
>f : (...x: any[]) => void
>x : any[]
}
f `0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n`
>f : (...x: any[]) => void

View file

@ -1,143 +1,69 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(5,10): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(9,17): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(13,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(16,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(20,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(23,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(27,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(28,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(29,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(33,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(34,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(35,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(39,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(40,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(41,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(45,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(46,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(47,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(51,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(52,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(53,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(57,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(58,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
Property 'z' is missing in type '{ x: number; y: string; }'.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(81,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(86,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(90,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (30 errors) ====
==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (2 errors) ====
// Generic tag with one parameter
function noParams<T>(n: T) { }
noParams ``;
~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with parameter which does not use type parameter
function noGenericParams<T>(n: string[]) { }
noGenericParams ``;
~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with multiple type parameters and only one used in parameter type annotation
function someGenerics1a<T, U>(n: T, m: number) { }
someGenerics1a `${3}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
function someGenerics1b<T, U>(n: string[], m: U) { }
someGenerics1b `${3}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with argument of function type whose parameter is of type parameter type
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
someGenerics2a `${(n: string) => n}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
someGenerics2b `${ (n: string, x: number) => n }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3<T>(strs: string[], producer: () => T) { }
someGenerics3 `${() => ''}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics3 `${() => undefined}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics3 `${() => 3}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
someGenerics4 `${4}${ () => null }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics4 `${''}${ () => 3 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics4 `${ null }${ null }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
someGenerics5 `${ 4 } ${ () => null }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics5 `${ '' }${ () => 3 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics5 `${null}${null}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with multiple arguments of function types that each have parameters of different generic type
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with argument of generic function type
function someGenerics8<T>(strs: string[], n: T): T { return n; }
var x = someGenerics8 `${ someGenerics7 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
x `${null}${null}${null}`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic tag with multiple parameters of generic type passed arguments with no best common type
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
@ -147,8 +73,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
~~~~~~~~~~~~~
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var a9a: {};
// Generic tag with multiple parameters of generic type passed arguments with multiple best common types
@ -166,27 +90,19 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
!!! error TS2453: Property 'z' is missing in type '{ x: number; y: string; }'.
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var a9e: {};
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var a9d: { x: number; };
// Generic tag with multiple parameters of generic type where one argument is of type 'any'
var anyVar: any;
var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var a: any;
// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any'
var arr = someGenerics9 `${ [] }${ null }${ undefined }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var arr: any[];

View file

@ -96,64 +96,65 @@ var arr: any[];
//// [taggedTemplateStringsTypeArgumentInference.js]
// Generic tag with one parameter
function noParams(n) { }
noParams "";
(_a = [""], _a.raw = [""], noParams(_a));
// Generic tag with parameter which does not use type parameter
function noGenericParams(n) { }
noGenericParams "";
(_b = [""], _b.raw = [""], noGenericParams(_b));
// Generic tag with multiple type parameters and only one used in parameter type annotation
function someGenerics1a(n, m) { }
someGenerics1a "" + 3;
(_c = ["", ""], _c.raw = ["", ""], someGenerics1a(_c, 3));
function someGenerics1b(n, m) { }
someGenerics1b "" + 3;
(_d = ["", ""], _d.raw = ["", ""], someGenerics1b(_d, 3));
// Generic tag with argument of function type whose parameter is of type parameter type
function someGenerics2a(strs, n) { }
someGenerics2a "" + function (n) { return n; };
(_e = ["", ""], _e.raw = ["", ""], someGenerics2a(_e, function (n) { return n; }));
function someGenerics2b(strs, n) { }
someGenerics2b "" + function (n, x) { return n; };
(_f = ["", ""], _f.raw = ["", ""], someGenerics2b(_f, function (n, x) { return n; }));
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3(strs, producer) { }
someGenerics3 "" + function () { return ''; };
someGenerics3 "" + function () { return undefined; };
someGenerics3 "" + function () { return 3; };
(_g = ["", ""], _g.raw = ["", ""], someGenerics3(_g, function () { return ''; }));
(_h = ["", ""], _h.raw = ["", ""], someGenerics3(_h, function () { return undefined; }));
(_j = ["", ""], _j.raw = ["", ""], someGenerics3(_j, function () { return 3; }));
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4(strs, n, f) { }
someGenerics4 "" + 4 + function () { return null; };
someGenerics4 "" + '' + function () { return 3; };
someGenerics4 "" + null + null;
(_k = ["", "", ""], _k.raw = ["", "", ""], someGenerics4(_k, 4, function () { return null; }));
(_l = ["", "", ""], _l.raw = ["", "", ""], someGenerics4(_l, '', function () { return 3; }));
(_m = ["", "", ""], _m.raw = ["", "", ""], someGenerics4(_m, null, null));
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5(strs, n, f) { }
someGenerics5 4 + " " + function () { return null; };
someGenerics5 "" + '' + function () { return 3; };
someGenerics5 "" + null + null;
(_n = ["", " ", ""], _n.raw = ["", " ", ""], someGenerics5(_n, 4, function () { return null; }));
(_o = ["", "", ""], _o.raw = ["", "", ""], someGenerics5(_o, '', function () { return 3; }));
(_p = ["", "", ""], _p.raw = ["", "", ""], someGenerics5(_p, null, null));
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6(strs, a, b, c) { }
someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; };
someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; };
someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; };
(_q = ["", "", "", ""], _q.raw = ["", "", "", ""], someGenerics6(_q, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_r = ["", "", "", ""], _r.raw = ["", "", "", ""], someGenerics6(_r, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_s = ["", "", "", ""], _s.raw = ["", "", "", ""], someGenerics6(_s, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
// Generic tag with multiple arguments of function types that each have parameters of different generic type
function someGenerics7(strs, a, b, c) { }
someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; };
someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; };
someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; };
(_t = ["", "", "", ""], _t.raw = ["", "", "", ""], someGenerics7(_t, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_u = ["", "", "", ""], _u.raw = ["", "", "", ""], someGenerics7(_u, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_v = ["", "", "", ""], _v.raw = ["", "", "", ""], someGenerics7(_v, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
// Generic tag with argument of generic function type
function someGenerics8(strs, n) { return n; }
var x = someGenerics8 "" + someGenerics7;
x "" + null + null + null;
var x = (_w = ["", ""], _w.raw = ["", ""], someGenerics8(_w, someGenerics7));
(_x = ["", "", "", ""], _x.raw = ["", "", "", ""], x(_x, null, null, null));
// Generic tag with multiple parameters of generic type passed arguments with no best common type
function someGenerics9(strs, a, b, c) {
return null;
}
var a9a = someGenerics9 "" + '' + 0 + [];
var a9a = (_y = ["", "", "", ""], _y.raw = ["", "", "", ""], someGenerics9(_y, '', 0, []));
var a9a;
var a9e = someGenerics9 "" + undefined + { x: 6, z: new Date() } + { x: 6, y: '' };
var a9e = (_z = ["", "", "", ""], _z.raw = ["", "", "", ""], someGenerics9(_z, undefined, { x: 6, z: new Date() }, { x: 6, y: '' }));
var a9e;
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
var a9d = someGenerics9 "" + { x: 3 } + { x: 6 } + { x: 6 };
var a9d = (_0 = ["", "", "", ""], _0.raw = ["", "", "", ""], someGenerics9(_0, { x: 3 }, { x: 6 }, { x: 6 }));
var a9d;
// Generic tag with multiple parameters of generic type where one argument is of type 'any'
var anyVar;
var a = someGenerics9 "" + 7 + anyVar + 4;
var a = (_1 = ["", "", "", ""], _1.raw = ["", "", "", ""], someGenerics9(_1, 7, anyVar, 4));
var a;
// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any'
var arr = someGenerics9 "" + [] + null + undefined;
var arr = (_2 = ["", "", "", ""], _2.raw = ["", "", "", ""], someGenerics9(_2, [], null, undefined));
var arr;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;

View file

@ -1,24 +1,12 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,19): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,40): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,50): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (18 errors) ====
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (6 errors) ====
interface I {
(stringParts: string[], ...rest: boolean[]): I;
g: I;
@ -31,56 +19,32 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
var f: I;
f `abc`
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
f `abc`.member
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`.member;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
f `abc`["member"];
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`["member"];
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
f `abc`[0].member `abc${1}def${2}ghi`;
~~~~~
!!! 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 TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
~~~~~~
!!! 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 TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.

View file

@ -35,14 +35,15 @@ f.thisIsNotATag(`abc${1}def${2}ghi`);
//// [taggedTemplateStringsWithIncompatibleTypedTags.js]
var f;
f "abc";
f "abc" + 1 + "def" + 2 + "ghi";
f "abc".member;
f "abc" + 1 + "def" + 2 + "ghi".member;
f "abc"["member"];
f "abc" + 1 + "def" + 2 + "ghi"["member"];
f "abc"[0].member "abc" + 1 + "def" + 2 + "ghi";
f "abc" + 1 + "def" + 2 + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi";
f "abc" + true + "def" + true + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi";
(_a = ["abc"], _a.raw = ["abc"], f(_a));
(_b = ["abc", "def", "ghi"], _b.raw = ["abc", "def", "ghi"], f(_b, 1, 2));
(_c = ["abc"], _c.raw = ["abc"], f(_c)).member;
(_d = ["abc", "def", "ghi"], _d.raw = ["abc", "def", "ghi"], f(_d, 1, 2)).member;
(_e = ["abc"], _e.raw = ["abc"], f(_e))["member"];
(_f = ["abc", "def", "ghi"], _f.raw = ["abc", "def", "ghi"], f(_f, 1, 2))["member"];
(_g = ["abc", "def", "ghi"], _g.raw = ["abc", "def", "ghi"], (_h = ["abc"], _h.raw = ["abc"], f(_h))[0].member(_g, 1, 2));
(_j = ["abc", "def", "ghi"], _j.raw = ["abc", "def", "ghi"], (_k = ["abc", "def", "ghi"], _k.raw = ["abc", "def", "ghi"], f(_k, 1, 2))["member"].member(_j, 1, 2));
(_l = ["abc", "def", "ghi"], _l.raw = ["abc", "def", "ghi"], (_m = ["abc", "def", "ghi"], _m.raw = ["abc", "def", "ghi"], f(_m, true, true))["member"].member(_l, 1, 2));
f.thisIsNotATag("abc");
f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi");
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;

View file

@ -1,21 +0,0 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ====
interface I {
(strs: string[], ...subs: number[]): I;
member: {
new (s: string): {
new (n: number): {
new (): boolean;
}
}
};
}
var f: I;
var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.

View file

@ -17,4 +17,5 @@ var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
//// [taggedTemplateStringsWithManyCallAndMemberExpressions.js]
var f;
var x = new new new f "abc" + 0 + "def".member("hello")(42) === true;
var x = new new new (_a = ["abc", "def"], _a.raw = ["abc", "def"], f(_a, 0)).member("hello")(42) === true;
var _a;

View file

@ -0,0 +1,38 @@
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts ===
interface I {
>I : I
(strs: string[], ...subs: number[]): I;
>strs : string[]
>subs : number[]
>I : I
member: {
>member : new (s: string) => new (n: number) => new () => boolean
new (s: string): {
>s : string
new (n: number): {
>n : number
new (): boolean;
}
}
};
}
var f: I;
>f : I
>I : I
var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
>x : boolean
>new new new f `abc${ 0 }def`.member("hello")(42) === true : boolean
>new new new f `abc${ 0 }def`.member("hello")(42) : boolean
>new new f `abc${ 0 }def`.member("hello")(42) : new () => boolean
>new f `abc${ 0 }def`.member("hello") : new (n: number) => new () => boolean
>f `abc${ 0 }def`.member : new (s: string) => new (n: number) => new () => boolean
>f : I
>member : new (s: string) => new (n: number) => new () => boolean

View file

@ -0,0 +1,18 @@
//// [taggedTemplateStringsWithMultilineTemplate.ts]
function f(...args: any[]): void {
}
f `
\
`;
//// [taggedTemplateStringsWithMultilineTemplate.js]
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
(_a = ["\n\n"], _a.raw = ["\n\\\n\n"], f(_a));
var _a;

View file

@ -0,0 +1,12 @@
=== tests/cases/compiler/taggedTemplateStringsWithMultilineTemplate.ts ===
function f(...args: any[]): void {
>f : (...args: any[]) => void
>args : any[]
}
f `
>f : (...args: any[]) => void
\
`;

View file

@ -0,0 +1,16 @@
//// [taggedTemplateStringsWithMultilineTemplateES6.ts]
function f(...args: any[]): void {
}
f `
\
`;
//// [taggedTemplateStringsWithMultilineTemplateES6.js]
function f(...args) {
}
f `
\
`;

View file

@ -0,0 +1,12 @@
=== tests/cases/compiler/taggedTemplateStringsWithMultilineTemplateES6.ts ===
function f(...args: any[]): void {
>f : (...args: any[]) => void
>args : any[]
}
f `
>f : (...args: any[]) => void
\
`;

View file

@ -1,16 +1,10 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (10 errors) ====
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (4 errors) ====
function foo(strs: string[]): number;
function foo(strs: string[], x: number): string;
function foo(strs: string[], x: number, y: number): boolean;
@ -31,25 +25,13 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
!!! error TS2346: Supplied parameters do not match any signature of call target.
var u = foo ``; // number
~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var v = foo `${1}`; // string
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var w = foo `${1}${2}`; // boolean
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var x = foo `${1}${true}`; // boolean (with error)
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
var y = foo `${1}${"2"}`; // {}
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var z = foo `${1}${2}${3}`; // any (with error)
~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.

View file

@ -36,9 +36,10 @@ var c = foo([], 1, 2); // boolean
var d = foo([], 1, true); // boolean (with error)
var e = foo([], 1, "2"); // {}
var f = foo([], 1, 2, 3); // any (with error)
var u = foo ""; // number
var v = foo "" + 1; // string
var w = foo "" + 1 + 2; // boolean
var x = foo "" + 1 + true; // boolean (with error)
var y = foo "" + 1 + "2"; // {}
var z = foo "" + 1 + 2 + 3; // any (with error)
var u = (_a = [""], _a.raw = [""], foo(_a)); // number
var v = (_b = ["", ""], _b.raw = ["", ""], foo(_b, 1)); // string
var w = (_c = ["", "", ""], _c.raw = ["", "", ""], foo(_c, 1, 2)); // boolean
var x = (_d = ["", "", ""], _d.raw = ["", "", ""], foo(_d, 1, true)); // boolean (with error)
var y = (_e = ["", "", ""], _e.raw = ["", "", ""], foo(_e, 1, "2")); // {}
var z = (_f = ["", "", "", ""], _f.raw = ["", "", "", ""], foo(_f, 1, 2, 3)); // any (with error)
var _a, _b, _c, _d, _e, _f;

View file

@ -1,27 +0,0 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts(8,14): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts(17,14): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts (2 errors) ====
function foo1(strs: TemplateStringsArray, x: number): string;
function foo1(strs: string[], x: number): number;
function foo1(...stuff: any[]): any {
return undefined;
}
var a = foo1 `${1}`; // string
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var b = foo1([], 1); // number
function foo2(strs: string[], x: number): number;
function foo2(strs: TemplateStringsArray, x: number): string;
function foo2(...stuff: any[]): any {
return undefined;
}
var c = foo2 `${1}`; // number
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var d = foo2([], 1); // number

View file

@ -26,7 +26,7 @@ function foo1() {
}
return undefined;
}
var a = foo1 "" + 1; // string
var a = (_a = ["", ""], _a.raw = ["", ""], foo1(_a, 1)); // string
var b = foo1([], 1); // number
function foo2() {
var stuff = [];
@ -35,5 +35,6 @@ function foo2() {
}
return undefined;
}
var c = foo2 "" + 1; // number
var c = (_b = ["", ""], _b.raw = ["", ""], foo2(_b, 1)); // number
var d = foo2([], 1); // number
var _a, _b;

View file

@ -0,0 +1,60 @@
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts ===
function foo1(strs: TemplateStringsArray, x: number): string;
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
>strs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>x : number
function foo1(strs: string[], x: number): number;
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
>strs : string[]
>x : number
function foo1(...stuff: any[]): any {
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
>stuff : any[]
return undefined;
>undefined : undefined
}
var a = foo1 `${1}`; // string
>a : string
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
var b = foo1([], 1); // number
>b : number
>foo1([], 1) : number
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
>[] : undefined[]
function foo2(strs: string[], x: number): number;
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
>strs : string[]
>x : number
function foo2(strs: TemplateStringsArray, x: number): string;
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
>strs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>x : number
function foo2(...stuff: any[]): any {
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
>stuff : any[]
return undefined;
>undefined : undefined
}
var c = foo2 `${1}`; // number
>c : number
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
var d = foo2([], 1); // number
>d : number
>foo2([], 1) : number
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
>[] : undefined[]

View file

@ -1,34 +1,12 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(7,21): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(16,20): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(17,20): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(19,4): error TS2339: Property 'foo' does not exist on type 'Date'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(23,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(26,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(34,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(35,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(36,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(40,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(41,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(42,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(54,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(55,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(56,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(57,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(60,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,18): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,18): error TS2339: Property 'toFixed' does not exist on type 'string'.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(71,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts (28 errors) ====
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts (6 errors) ====
// Ambiguous call picks the first overload in declaration order
function fn1(strs: TemplateStringsArray, s: string): string;
@ -36,13 +14,9 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
function fn1() { return null; }
var s: string = fn1 `${ undefined }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// No candidate overloads found
fn1 `${ {} }`; // Error
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~~
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
@ -51,11 +25,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
function fn2() { return undefined; }
var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var d2 = fn2 `${ 0 }${ undefined }`; // any
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
d1.foo(); // error
~~~
@ -64,13 +34,9 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
// Generic and non-generic overload where generic overload is the only candidate
fn2 `${ 0 }${ '' }`; // OK
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic and non-generic overload where non-generic overload is the only candidate
fn2 `${ '' }${ 0 }`; // OK
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic overloads with differing arity
function fn3<T>(strs: TemplateStringsArray, n: T): string;
@ -79,33 +45,19 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
function fn3() { return null; }
var s = fn3 `${ 3 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var s = fn3 `${'' }${ 3 }${ '' }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var n = fn3 `${ 5 }${ 5 }${ 5 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var n: number;
// Generic overloads with differing arity tagging with arguments matching each overload type parameter count
var s = fn3 `${ 4 }`
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var s = fn3 `${ '' }${ '' }${ '' }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
var n = fn3 `${ '' }${ '' }${ 3 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic overloads with differing arity tagging with argument count that doesn't match any overload
fn3 ``; // Error
~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic overloads with constraints
function fn4<T extends string, U extends number>(strs: TemplateStringsArray, n: T, m: U);
@ -115,32 +67,18 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
// Generic overloads with constraints tagged with types that satisfy the constraints
fn4 `${ '' }${ 3 }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
fn4 `${ 3 }${ '' }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
fn4 `${ 3 }${ undefined }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
fn4 `${ '' }${ null }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
fn4 `${ null }${ null }`; // Error
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
fn4 `${ true }${ null }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
fn4 `${ null }${ true }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
@ -149,12 +87,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
function fn5(strs: TemplateStringsArray, f: (n: number) => void): number;
function fn5() { return undefined; }
fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'.
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~~~~~~~
!!! error TS2339: Property 'toFixed' does not exist on type 'string'.
fn5 `${ (n) => n.substr(0) }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.

View file

@ -75,40 +75,41 @@ fn5 `${ (n) => n.substr(0) }`;
//// [taggedTemplateStringsWithOverloadResolution3.js]
function fn1() { return null; }
var s = fn1 "" + undefined;
var s = (_a = ["", ""], _a.raw = ["", ""], fn1(_a, undefined));
// No candidate overloads found
fn1 "" + {}; // Error
(_b = ["", ""], _b.raw = ["", ""], fn1(_b, {})); // Error
function fn2() { return undefined; }
var d1 = fn2 "" + 0 + undefined; // contextually typed
var d2 = fn2 "" + 0 + undefined; // any
var d1 = (_c = ["", "", ""], _c.raw = ["", "", ""], fn2(_c, 0, undefined)); // contextually typed
var d2 = (_d = ["", "", ""], _d.raw = ["", "", ""], fn2(_d, 0, undefined)); // any
d1.foo(); // error
d2(); // no error (typed as any)
// Generic and non-generic overload where generic overload is the only candidate
fn2 "" + 0 + ''; // OK
(_e = ["", "", ""], _e.raw = ["", "", ""], fn2(_e, 0, '')); // OK
// Generic and non-generic overload where non-generic overload is the only candidate
fn2 "" + '' + 0; // OK
(_f = ["", "", ""], _f.raw = ["", "", ""], fn2(_f, '', 0)); // OK
function fn3() { return null; }
var s = fn3 "" + 3;
var s = fn3 "" + '' + 3 + '';
var n = fn3 "" + 5 + 5 + 5;
var s = (_g = ["", ""], _g.raw = ["", ""], fn3(_g, 3));
var s = (_h = ["", "", "", ""], _h.raw = ["", "", "", ""], fn3(_h, '', 3, ''));
var n = (_j = ["", "", "", ""], _j.raw = ["", "", "", ""], fn3(_j, 5, 5, 5));
var n;
// Generic overloads with differing arity tagging with arguments matching each overload type parameter count
var s = fn3 "" + 4;
var s = fn3 "" + '' + '' + '';
var n = fn3 "" + '' + '' + 3;
var s = (_k = ["", ""], _k.raw = ["", ""], fn3(_k, 4));
var s = (_l = ["", "", "", ""], _l.raw = ["", "", "", ""], fn3(_l, '', '', ''));
var n = (_m = ["", "", "", ""], _m.raw = ["", "", "", ""], fn3(_m, '', '', 3));
// Generic overloads with differing arity tagging with argument count that doesn't match any overload
fn3 ""; // Error
(_n = [""], _n.raw = [""], fn3(_n)); // Error
function fn4() { }
// Generic overloads with constraints tagged with types that satisfy the constraints
fn4 "" + '' + 3;
fn4 "" + 3 + '';
fn4 "" + 3 + undefined;
fn4 "" + '' + null;
(_o = ["", "", ""], _o.raw = ["", "", ""], fn4(_o, '', 3));
(_p = ["", "", ""], _p.raw = ["", "", ""], fn4(_p, 3, ''));
(_q = ["", "", ""], _q.raw = ["", "", ""], fn4(_q, 3, undefined));
(_r = ["", "", ""], _r.raw = ["", "", ""], fn4(_r, '', null));
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
fn4 "" + null + null; // Error
(_s = ["", "", ""], _s.raw = ["", "", ""], fn4(_s, null, null)); // Error
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
fn4 "" + true + null;
fn4 "" + null + true;
(_t = ["", "", ""], _t.raw = ["", "", ""], fn4(_t, true, null));
(_u = ["", "", ""], _u.raw = ["", "", ""], fn4(_u, null, true));
function fn5() { return undefined; }
fn5 "" + function (n) { return n.toFixed(); }; // will error; 'n' should have type 'string'.
fn5 "" + function (n) { return n.substr(0); };
(_v = ["", ""], _v.raw = ["", ""], fn5(_v, function (n) { return n.toFixed(); })); // will error; 'n' should have type 'string'.
(_w = ["", ""], _w.raw = ["", ""], fn5(_w, function (n) { return n.substr(0); }));
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;

View file

@ -1,64 +0,0 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,7): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,7): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,32): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,46): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (12 errors) ====
var f: any;
f `abc`
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f.g.h `abc`
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f.g.h `abc${1}def${2}ghi`;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc`.member
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`.member;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc`["member"];
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`["member"];
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc`["member"].someOtherTag `abc${1}def${2}ghi`;
~~~~~
!!! 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.
f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`;
~~~~~~
!!! 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.
f.thisIsNotATag(`abc`);
f.thisIsNotATag(`abc${1}def${2}ghi`);

View file

@ -27,15 +27,16 @@ f.thisIsNotATag(`abc${1}def${2}ghi`);
//// [taggedTemplateStringsWithTagsTypedAsAny.js]
var f;
f "abc";
f "abc" + 1 + "def" + 2 + "ghi";
f.g.h "abc";
f.g.h "abc" + 1 + "def" + 2 + "ghi";
f "abc".member;
f "abc" + 1 + "def" + 2 + "ghi".member;
f "abc"["member"];
f "abc" + 1 + "def" + 2 + "ghi"["member"];
f "abc"["member"].someOtherTag "abc" + 1 + "def" + 2 + "ghi";
f "abc" + 1 + "def" + 2 + "ghi"["member"].someOtherTag "abc" + 1 + "def" + 2 + "ghi";
(_a = ["abc"], _a.raw = ["abc"], f(_a));
(_b = ["abc", "def", "ghi"], _b.raw = ["abc", "def", "ghi"], f(_b, 1, 2));
(_c = ["abc"], _c.raw = ["abc"], f.g.h(_c));
(_d = ["abc", "def", "ghi"], _d.raw = ["abc", "def", "ghi"], f.g.h(_d, 1, 2));
(_e = ["abc"], _e.raw = ["abc"], f(_e)).member;
(_f = ["abc", "def", "ghi"], _f.raw = ["abc", "def", "ghi"], f(_f, 1, 2)).member;
(_g = ["abc"], _g.raw = ["abc"], f(_g))["member"];
(_h = ["abc", "def", "ghi"], _h.raw = ["abc", "def", "ghi"], f(_h, 1, 2))["member"];
(_j = ["abc", "def", "ghi"], _j.raw = ["abc", "def", "ghi"], (_k = ["abc"], _k.raw = ["abc"], f(_k))["member"].someOtherTag(_j, 1, 2));
(_l = ["abc", "def", "ghi"], _l.raw = ["abc", "def", "ghi"], (_m = ["abc", "def", "ghi"], _m.raw = ["abc", "def", "ghi"], f(_m, 1, 2))["member"].someOtherTag(_l, 1, 2));
f.thisIsNotATag("abc");
f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi");
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;

View file

@ -0,0 +1,66 @@
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts ===
var f: any;
>f : any
f `abc`
>f : any
f `abc${1}def${2}ghi`;
>f : any
f.g.h `abc`
>f.g.h : any
>f.g : any
>f : any
>g : any
>h : any
f.g.h `abc${1}def${2}ghi`;
>f.g.h : any
>f.g : any
>f : any
>g : any
>h : any
f `abc`.member
>f `abc`.member : any
>f : any
>member : any
f `abc${1}def${2}ghi`.member;
>f `abc${1}def${2}ghi`.member : any
>f : any
>member : any
f `abc`["member"];
>f `abc`["member"] : any
>f : any
f `abc${1}def${2}ghi`["member"];
>f `abc${1}def${2}ghi`["member"] : any
>f : any
f `abc`["member"].someOtherTag `abc${1}def${2}ghi`;
>f `abc`["member"].someOtherTag : any
>f `abc`["member"] : any
>f : any
>someOtherTag : any
f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`;
>f `abc${1}def${2}ghi`["member"].someOtherTag : any
>f `abc${1}def${2}ghi`["member"] : any
>f : any
>someOtherTag : any
f.thisIsNotATag(`abc`);
>f.thisIsNotATag(`abc`) : any
>f.thisIsNotATag : any
>f : any
>thisIsNotATag : any
f.thisIsNotATag(`abc${1}def${2}ghi`);
>f.thisIsNotATag(`abc${1}def${2}ghi`) : any
>f.thisIsNotATag : any
>f : any
>thisIsNotATag : any

View file

@ -1,15 +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(6,31): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (2 errors) ====
==== 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.
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.

View file

@ -13,4 +13,5 @@ function foo() {
rest[_i - 0] = arguments[_i];
}
}
foo "" + function (x) { x = "bad"; };
(_a = ["", ""], _a.raw = ["", ""], foo(_a, function (x) { x = "bad"; }));
var _a;

View file

@ -1,64 +0,0 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(12,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(14,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,19): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,40): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts (10 errors) ====
interface I {
(stringParts: string[], ...rest: number[]): I;
g: I;
h: I;
member: I;
thisIsNotATag(x: string): void
[x: number]: I;
}
var f: I;
f `abc`
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc`.member
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`.member;
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc`["member"];
~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc${1}def${2}ghi`["member"];
~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abc`[0].member `abc${1}def${2}ghi`;
~~~~~
!!! 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.
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
~~~~~~
!!! 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.
f.thisIsNotATag(`abc`);
f.thisIsNotATag(`abc${1}def${2}ghi`);

View file

@ -33,13 +33,14 @@ f.thisIsNotATag(`abc${1}def${2}ghi`);
//// [taggedTemplateStringsWithTypedTags.js]
var f;
f "abc";
f "abc" + 1 + "def" + 2 + "ghi";
f "abc".member;
f "abc" + 1 + "def" + 2 + "ghi".member;
f "abc"["member"];
f "abc" + 1 + "def" + 2 + "ghi"["member"];
f "abc"[0].member "abc" + 1 + "def" + 2 + "ghi";
f "abc" + 1 + "def" + 2 + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi";
(_a = ["abc"], _a.raw = ["abc"], f(_a));
(_b = ["abc", "def", "ghi"], _b.raw = ["abc", "def", "ghi"], f(_b, 1, 2));
(_c = ["abc"], _c.raw = ["abc"], f(_c)).member;
(_d = ["abc", "def", "ghi"], _d.raw = ["abc", "def", "ghi"], f(_d, 1, 2)).member;
(_e = ["abc"], _e.raw = ["abc"], f(_e))["member"];
(_f = ["abc", "def", "ghi"], _f.raw = ["abc", "def", "ghi"], f(_f, 1, 2))["member"];
(_g = ["abc", "def", "ghi"], _g.raw = ["abc", "def", "ghi"], (_h = ["abc"], _h.raw = ["abc"], f(_h))[0].member(_g, 1, 2));
(_j = ["abc", "def", "ghi"], _j.raw = ["abc", "def", "ghi"], (_k = ["abc", "def", "ghi"], _k.raw = ["abc", "def", "ghi"], f(_k, 1, 2))["member"].member(_j, 1, 2));
f.thisIsNotATag("abc");
f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi");
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;

View file

@ -0,0 +1,82 @@
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts ===
interface I {
>I : I
(stringParts: string[], ...rest: number[]): I;
>stringParts : string[]
>rest : number[]
>I : I
g: I;
>g : I
>I : I
h: I;
>h : I
>I : I
member: I;
>member : I
>I : I
thisIsNotATag(x: string): void
>thisIsNotATag : (x: string) => void
>x : string
[x: number]: I;
>x : number
>I : I
}
var f: I;
>f : I
>I : I
f `abc`
>f : I
f `abc${1}def${2}ghi`;
>f : I
f `abc`.member
>f `abc`.member : I
>f : I
>member : I
f `abc${1}def${2}ghi`.member;
>f `abc${1}def${2}ghi`.member : I
>f : I
>member : I
f `abc`["member"];
>f `abc`["member"] : I
>f : I
f `abc${1}def${2}ghi`["member"];
>f `abc${1}def${2}ghi`["member"] : I
>f : I
f `abc`[0].member `abc${1}def${2}ghi`;
>f `abc`[0].member : I
>f `abc`[0] : I
>f : I
>member : I
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
>f `abc${1}def${2}ghi`["member"].member : I
>f `abc${1}def${2}ghi`["member"] : I
>f : I
>member : I
f.thisIsNotATag(`abc`);
>f.thisIsNotATag(`abc`) : void
>f.thisIsNotATag : (x: string) => void
>f : I
>thisIsNotATag : (x: string) => void
f.thisIsNotATag(`abc${1}def${2}ghi`);
>f.thisIsNotATag(`abc${1}def${2}ghi`) : void
>f.thisIsNotATag : (x: string) => void
>f : I
>thisIsNotATag : (x: string) => void

View file

@ -0,0 +1,10 @@
tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts(4,7): error TS1125: Hexadecimal digit expected.
==== tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapes.ts (1 errors) ====
function f(...args: any[]) {
}
f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`;
!!! error TS1125: Hexadecimal digit expected.

View file

@ -0,0 +1,15 @@
//// [taggedTemplateStringsWithUnicodeEscapes.ts]
function f(...args: any[]) {
}
f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`;
//// [taggedTemplateStringsWithUnicodeEscapes.js]
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
(_a = ["'{1f4a9}'", "'💩'"], _a.raw = ["'\\u{1f4a9}'", "'\\uD83D\\uDCA9'"], f(_a, " should be converted to "));
var _a;

View file

@ -0,0 +1,10 @@
tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts(4,7): error TS1125: Hexadecimal digit expected.
==== tests/cases/compiler/taggedTemplateStringsWithUnicodeEscapesES6.ts (1 errors) ====
function f(...args: any[]) {
}
f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`;
!!! error TS1125: Hexadecimal digit expected.

View file

@ -0,0 +1,10 @@
//// [taggedTemplateStringsWithUnicodeEscapesES6.ts]
function f(...args: any[]) {
}
f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`;
//// [taggedTemplateStringsWithUnicodeEscapesES6.js]
function f(...args) {
}
f `'\u{1f4a9}'${" should be converted to "}'\uD83D\uDCA9'`;

View file

@ -0,0 +1,15 @@
//// [taggedTemplateStringsWithWhitespaceEscapes.ts]
function f(...args: any[]) {
}
f `\t\n\v\f\r\\`;
//// [taggedTemplateStringsWithWhitespaceEscapes.js]
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
(_a = ["\t\n\v\f\r\\"], _a.raw = ["\\t\\n\\v\\f\\r\\\\"], f(_a));
var _a;

View file

@ -0,0 +1,9 @@
=== tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapes.ts ===
function f(...args: any[]) {
>f : (...args: any[]) => void
>args : any[]
}
f `\t\n\v\f\r\\`;
>f : (...args: any[]) => void

View file

@ -0,0 +1,10 @@
//// [taggedTemplateStringsWithWhitespaceEscapesES6.ts]
function f(...args: any[]) {
}
f `\t\n\v\f\r\\`;
//// [taggedTemplateStringsWithWhitespaceEscapesES6.js]
function f(...args) {
}
f `\t\n\v\f\r\\`;

View file

@ -0,0 +1,9 @@
=== tests/cases/compiler/taggedTemplateStringsWithWhitespaceEscapesES6.ts ===
function f(...args: any[]) {
>f : (...args: any[]) => void
>args : any[]
}
f `\t\n\v\f\r\\`;
>f : (...args: any[]) => void

View file

@ -7,10 +7,11 @@ declare module `M${2}` {
//// [templateStringInModuleName.js]
declare;
module "M1";
(_a = ["M1"], _a.raw = ["M1"], module(_a));
{
}
declare;
module "M" + 2;
(_b = ["M", ""], _b.raw = ["M", ""], module(_b, 2));
{
}
var _a, _b;

View file

@ -5,6 +5,7 @@ var x = {
}
//// [templateStringInObjectLiteral.js]
var x = {
a: "abc" + 123 + "def" } "b";
var x = (_a = ["b"], _a.raw = ["b"], ({
a: "abc" + 123 + "def" })(_a));
321;
var _a;

View file

@ -4,5 +4,6 @@ var x = {
}
//// [templateStringInPropertyName1.js]
var x = {} "a";
var x = (_a = ["a"], _a.raw = ["a"], ({})(_a));
321;
var _a;

View file

@ -4,5 +4,6 @@ var x = {
}
//// [templateStringInPropertyName2.js]
var x = {} "abc" + 123 + "def" + 456 + "ghi";
var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], ({})(_a, 123, 456));
321;
var _a;

View file

@ -1,10 +1,7 @@
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(1,42): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts (2 errors) ====
==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.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.
~~~~~
!!! 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

@ -2,4 +2,5 @@
`I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION`
//// [templateStringInTaggedTemplate.js]
"I AM THE " + "TAG" + " " + " PORTION" "I " + "AM" + " THE TEMPLATE PORTION";
(_a = ["I ", " THE TEMPLATE PORTION"], _a.raw = ["I ", " THE TEMPLATE PORTION"], ("I AM THE " + "TAG" + " " + " PORTION")(_a, "AM"));
var _a;

View file

@ -2,10 +2,9 @@ lib.d.ts(515,11): error TS2300: Duplicate identifier 'TemplateStringsArray'.
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'.
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
Property 'raw' is missing in type '{ [x: number]: undefined; }'.
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (3 errors) ====
==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ====
class TemplateStringsArray {
~~~~~~~~~~~~~~~~~~~~
@ -20,6 +19,4 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS
!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'.
f `abcdef${ 1234 }${ 5678 }ghijkl`;
~~~~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abcdef${ 1234 }${ 5678 }ghijkl`;

View file

@ -19,4 +19,5 @@ var TemplateStringsArray = (function () {
function f(x, y, z) {
}
f({}, 10, 10);
f "abcdef" + 1234 + 5678 + "ghijkl";
(_a = ["abcdef", "", "ghijkl"], _a.raw = ["abcdef", "", "ghijkl"], f(_a, 1234, 5678));
var _a;

View file

@ -1,9 +1,8 @@
tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(5,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
Property 'raw' is missing in type '{ [x: number]: undefined; }'.
tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(7,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
==== tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts (2 errors) ====
==== tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts (1 errors) ====
function f(x: TemplateStringsArray, y: number, z: number) {
}
@ -13,6 +12,4 @@ tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(7,3): error TS
!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'.
f `abcdef${ 1234 }${ 5678 }ghijkl`;
~~~~~~~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
f `abcdef${ 1234 }${ 5678 }ghijkl`;

View file

@ -11,4 +11,5 @@ f `abcdef${ 1234 }${ 5678 }ghijkl`;
function f(x, y, z) {
}
f({}, 10, 10);
f "abcdef" + 1234 + 5678 + "ghijkl";
(_a = ["abcdef", "", "ghijkl"], _a.raw = ["abcdef", "", "ghijkl"], f(_a, 1234, 5678));
var _a;

View file

@ -0,0 +1,4 @@
function f(...args: any[]) {
}
f `\x0D${ "Interrupted CRLF" }\x0A`;

View file

@ -0,0 +1,5 @@
//@target: es6
function f(...args: any[]) {
}
f `\x0D${ "Interrupted CRLF" }\x0A`;

View file

@ -0,0 +1,7 @@
function f(...args: any[]): void {
}
f `
\
`;

View file

@ -0,0 +1,8 @@
//@target: es6
function f(...args: any[]): void {
}
f `
\
`;

View file

@ -0,0 +1,4 @@
function f(...args: any[]) {
}
f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`;

View file

@ -0,0 +1,5 @@
//@target: es6
function f(...args: any[]) {
}
f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`;

View file

@ -0,0 +1,4 @@
function f(...args: any[]) {
}
f `\t\n\v\f\r\\`;

View file

@ -0,0 +1,5 @@
//@target: es6
function f(...args: any[]) {
}
f `\t\n\v\f\r\\`;