Don't create errors directly when parsing template spans.

This commit is contained in:
Cyrus Najmabadi 2014-12-01 00:52:52 -08:00
parent 2f634b7e54
commit 94febee138
4 changed files with 3 additions and 9 deletions

View file

@ -119,7 +119,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." },
Invalid_template_literal_expected: { code: 1158, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" },
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." },

View file

@ -467,10 +467,6 @@
"category": "Error",
"code": 1157
},
"Invalid template literal; expected '}'": {
"category": "Error",
"code": 1158
},
"Tagged templates are only available when targeting ECMAScript 6 and higher.": {
"category": "Error",
"code": 1159

View file

@ -1676,13 +1676,12 @@ module ts {
literal = parseLiteralNode();
}
else {
error(Diagnostics.Invalid_template_literal_expected);
parseExpected(SyntaxKind.CloseBraceToken);
literal = <LiteralExpression>createMissingNode();
literal.text = "";
}
span.literal = literal;
return finishNode(span);
}

View file

@ -1,10 +1,10 @@
tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,19): error TS1158: Invalid template literal; expected '}'
tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,19): error TS1005: '}' expected.
tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,17): error TS2304: Cannot find name 'a'.
==== tests/cases/conformance/es6/templates/TemplateExpression1.ts (2 errors) ====
var v = `foo ${ a
!!! error TS1158: Invalid template literal; expected '}'
!!! error TS1005: '}' expected.
~
!!! error TS2304: Cannot find name 'a'.