mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 15:25:54 -06:00
Move grammar checking: taggedTemplateExpression
This commit is contained in:
parent
a4f17b1417
commit
b388eb3c2a
@ -6303,6 +6303,11 @@ module ts {
|
||||
}
|
||||
|
||||
function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type {
|
||||
// Grammar checking
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
|
||||
return getReturnTypeOfSignature(getResolvedSignature(node));
|
||||
}
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ module ts {
|
||||
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized", isEarly: true },
|
||||
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block.", isEarly: true },
|
||||
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block.", isEarly: true },
|
||||
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." },
|
||||
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.", isEarly: true },
|
||||
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.", isEarly: true },
|
||||
|
||||
@ -540,7 +540,8 @@
|
||||
},
|
||||
"Tagged templates are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1159
|
||||
"code": 1159,
|
||||
"isEarly": true
|
||||
},
|
||||
"Unterminated template literal.": {
|
||||
"category": "Error",
|
||||
|
||||
@ -4670,7 +4670,7 @@ module ts {
|
||||
case SyntaxKind.SourceFile: return checkSourceFile(<SourceFile>node);
|
||||
//case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(<ShorthandPropertyAssignment>node);
|
||||
//case SyntaxKind.SwitchStatement: return checkSwitchStatement(<SwitchStatement>node);
|
||||
case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(<TaggedTemplateExpression>node);
|
||||
//case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(<TaggedTemplateExpression>node);
|
||||
case SyntaxKind.ThrowStatement: return checkThrowStatement(<ThrowStatement>node);
|
||||
case SyntaxKind.TypeReference: return checkTypeReference(<TypeReferenceNode>node);
|
||||
case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(<VariableDeclaration>node);
|
||||
|
||||
@ -21,15 +21,15 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
|
||||
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; }'.
|
||||
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(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(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; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (30 errors) ====
|
||||
@ -143,11 +143,11 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
|
||||
return null;
|
||||
}
|
||||
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;
|
||||
~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~
|
||||
!!! 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
|
||||
@ -161,11 +161,11 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference
|
||||
}
|
||||
|
||||
var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`;
|
||||
~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~
|
||||
!!! 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 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
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
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(20,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
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(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(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) ====
|
||||
@ -48,8 +48,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
|
||||
~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! 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.
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
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.
|
||||
@ -10,6 +12,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
|
||||
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.
|
||||
@ -17,15 +20,12 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
|
||||
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(64,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
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(71,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(19,4): error TS2339: Property 'foo' does not exist on type 'Date'.
|
||||
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(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) ====
|
||||
@ -102,10 +102,10 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
|
||||
|
||||
// Generic overloads with differing arity tagging with argument count that doesn't match any overload
|
||||
fn3 ``; // Error
|
||||
~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~
|
||||
!!! 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);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
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) ====
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
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(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) ====
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user