Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow type aliases for object type literals #1025

Merged
merged 3 commits into from
Nov 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/compiler/diagnosticInformationMap.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ 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." },
Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead: { code: 1158, category: DiagnosticCategory.Error, key: "Aliased type cannot be an object type literal. Use an interface declaration instead." },
Invalid_template_literal_expected: { code: 1159, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" },
Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1160, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." },
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." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
Expand Down
8 changes: 2 additions & 6 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,13 @@
"category": "Error",
"code": 1157
},
"Aliased type cannot be an object type literal. Use an interface declaration instead.": {
"category": "Error",
"code": 1158
},
"Invalid template literal; expected '}'": {
"category": "Error",
"code": 1159
"code": 1158
},
"Tagged templates are only available when targeting ECMAScript 6 and higher.": {
"category": "Error",
"code": 1160
"code": 1159
},

"Duplicate identifier '{0}'.": {
Expand Down
7 changes: 0 additions & 7 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3856,13 +3856,6 @@ module ts {
parseExpected(SyntaxKind.EqualsToken);
node.type = parseType();
parseSemicolon();
var n = node.type;
while (n.kind === SyntaxKind.ParenType) {
n = (<ParenTypeNode>n).type;
}
if (n.kind === SyntaxKind.TypeLiteral && (n.pos !== (<TypeLiteralNode>n).members.pos || n.end !== (<TypeLiteralNode>n).members.end)) {
grammarErrorOnNode(node.type, Diagnostics.Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead);
}
return finishNode(node);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.


==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (10 errors) ====
Expand All @@ -24,39 +24,39 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped

f `abc`
~~~~~~~
!!! error TS1160: 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`;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1160: 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`.member
~~~~~~~
!!! error TS1160: 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;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1160: 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`["member"];
~~~~~~~
!!! error TS1160: 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"];
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1160: 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`[0].member `abc${1}def${2}ghi`;
~~~~~~~
!!! error TS1160: 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 TS1160: 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 TS1160: 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 TS1160: 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`);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.


==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ====
Expand All @@ -16,6 +16,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMember

var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
~~~~~~~~~~~~~~~~
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.


Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): 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 TS1160: 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`;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1160: 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.g.h `abc`
~~~~~~~~~~~
!!! error TS1160: 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.g.h `abc${1}def${2}ghi`;
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1160: 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`.member
~~~~~~~
!!! error TS1160: 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;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1160: 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`["member"];
~~~~~~~
!!! error TS1160: 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"];
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1160: 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`["member"].someOtherTag `abc${1}def${2}ghi`;
~~~~~~~
!!! error TS1160: 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 TS1160: 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 TS1160: 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 TS1160: 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`);

Expand Down
Loading