Skip to content

Commit 5b56d37

Browse files
committed
Merge pull request #1025 from Microsoft/aliasObjectTypeLiterals
Allow type aliases for object type literals
2 parents e7a451b + 0c5057e commit 5b56d37

14 files changed

+88
-100
lines changed

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ module ts {
120120
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" },
121121
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." },
122122
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." },
123-
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." },
124-
Invalid_template_literal_expected: { code: 1159, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" },
125-
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." },
123+
Invalid_template_literal_expected: { code: 1158, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" },
124+
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." },
126125
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
127126
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." },
128127
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,17 +471,13 @@
471471
"category": "Error",
472472
"code": 1157
473473
},
474-
"Aliased type cannot be an object type literal. Use an interface declaration instead.": {
475-
"category": "Error",
476-
"code": 1158
477-
},
478474
"Invalid template literal; expected '}'": {
479475
"category": "Error",
480-
"code": 1159
476+
"code": 1158
481477
},
482478
"Tagged templates are only available when targeting ECMAScript 6 and higher.": {
483479
"category": "Error",
484-
"code": 1160
480+
"code": 1159
485481
},
486482

487483
"Duplicate identifier '{0}'.": {

src/compiler/parser.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,13 +3856,6 @@ module ts {
38563856
parseExpected(SyntaxKind.EqualsToken);
38573857
node.type = parseType();
38583858
parseSemicolon();
3859-
var n = node.type;
3860-
while (n.kind === SyntaxKind.ParenType) {
3861-
n = (<ParenTypeNode>n).type;
3862-
}
3863-
if (n.kind === SyntaxKind.TypeLiteral && (n.pos !== (<TypeLiteralNode>n).members.pos || n.end !== (<TypeLiteralNode>n).members.end)) {
3864-
grammarErrorOnNode(node.type, Diagnostics.Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead);
3865-
}
38663859
return finishNode(node);
38673860
}
38683861

tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
2-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
3-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
4-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
5-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
6-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
7-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
8-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
9-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
10-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
1+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
2+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
3+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
6+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
7+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
8+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
9+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
10+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
1111

1212

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

2525
f `abc`
2626
~~~~~~~
27-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
27+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
2828

2929
f `abc${1}def${2}ghi`;
3030
~~~~~~~~~~~~~~~~~~~~~
31-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
31+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
3232

3333
f `abc`.member
3434
~~~~~~~
35-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
35+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
3636

3737
f `abc${1}def${2}ghi`.member;
3838
~~~~~~~~~~~~~~~~~~~~~
39-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
39+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4040

4141
f `abc`["member"];
4242
~~~~~~~
43-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
43+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4444

4545
f `abc${1}def${2}ghi`["member"];
4646
~~~~~~~~~~~~~~~~~~~~~
47-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
47+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4848

4949
f `abc`[0].member `abc${1}def${2}ghi`;
5050
~~~~~~~
51-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
51+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5252
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
53+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5454

5555
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
5656
~~~~~~~~~~~~~~~~~~~~~
57-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
57+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5858
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
59+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
6060

6161
f.thisIsNotATag(`abc`);
6262

tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
1+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
22

33

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

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

2121

tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
2-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
3-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
4-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
5-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
6-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
7-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
8-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
9-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
10-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
11-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
12-
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
1+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
2+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
3+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
6+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
7+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
8+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
9+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
10+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
11+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
12+
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
1313

1414

1515
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (12 errors) ====
1616
var f: any;
1717

1818
f `abc`
1919
~~~~~~~
20-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
20+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
2121

2222
f `abc${1}def${2}ghi`;
2323
~~~~~~~~~~~~~~~~~~~~~
24-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
24+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
2525

2626
f.g.h `abc`
2727
~~~~~~~~~~~
28-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
28+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
2929

3030
f.g.h `abc${1}def${2}ghi`;
3131
~~~~~~~~~~~~~~~~~~~~~~~~~
32-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
32+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
3333

3434
f `abc`.member
3535
~~~~~~~
36-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
36+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
3737

3838
f `abc${1}def${2}ghi`.member;
3939
~~~~~~~~~~~~~~~~~~~~~
40-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
40+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4141

4242
f `abc`["member"];
4343
~~~~~~~
44-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
44+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4545

4646
f `abc${1}def${2}ghi`["member"];
4747
~~~~~~~~~~~~~~~~~~~~~
48-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
48+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
4949

5050
f `abc`["member"].someOtherTag `abc${1}def${2}ghi`;
5151
~~~~~~~
52-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
52+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5353
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
54+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5555

5656
f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`;
5757
~~~~~~~~~~~~~~~~~~~~~
58-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
58+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
5959
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60-
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
60+
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
6161

6262
f.thisIsNotATag(`abc`);
6363

0 commit comments

Comments
 (0)