Skip to content

Commit ee3ba3b

Browse files
CR feedback.
1 parent 93ff9e6 commit ee3ba3b

17 files changed

+92
-79
lines changed

src/compiler/checker.ts

Lines changed: 60 additions & 44 deletions
Large diffs are not rendered by default.

src/compiler/declarationEmitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,11 +892,11 @@ module ts {
892892
let prevEnclosingDeclaration = enclosingDeclaration;
893893
enclosingDeclaration = node;
894894
emitTypeParameters(node.typeParameters);
895-
let baseTypeNode = getClassBaseTypeNode(node);
895+
let baseTypeNode = getClassExtendsHeritageClauseElement(node);
896896
if (baseTypeNode) {
897897
emitHeritageClause([baseTypeNode], /*isImplementsList*/ false);
898898
}
899-
emitHeritageClause(getClassImplementedTypeNodes(node), /*isImplementsList*/ true);
899+
emitHeritageClause(getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true);
900900
write(" {");
901901
writeLine();
902902
increaseIndent();

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ module ts {
353353
The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." },
354354
External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." },
355355
External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." },
356-
An_interface_can_only_extend_a_type_reference: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend a type reference." },
357-
A_class_can_only_implement_type_references: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement type references." },
356+
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." },
357+
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." },
358358
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
359359
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
360360
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -507,7 +507,7 @@ module ts {
507507
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
508508
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
509509
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
510-
Only_type_references_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only type references are currently supported in a class 'extends' clauses." },
510+
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },
511511
class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." },
512512
class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." },
513513
};

src/compiler/diagnosticMessages.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,11 @@
14031403
"category": "Error",
14041404
"code": 2498
14051405
},
1406-
"An interface can only extend a type reference.": {
1406+
"An interface can only extend an identifier/qualified-name with optional type arguments.": {
14071407
"category": "Error",
14081408
"code": 2499
14091409
},
1410-
"A class can only implement type references.": {
1410+
"A class can only implement an identifier/qualified-name with optional type arguments.": {
14111411
"category": "Error",
14121412
"code": 2500
14131413
},
@@ -2021,7 +2021,7 @@
20212021
"category": "Error",
20222022
"code": 9001
20232023
},
2024-
"Only type references are currently supported in a class 'extends' clauses.": {
2024+
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": {
20252025
"category": "Error",
20262026
"code": 9002
20272027
},

src/compiler/emitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,7 +3547,7 @@ module ts {
35473547
emitDeclarationName(node);
35483548
}
35493549

3550-
var baseTypeNode = getClassBaseTypeNode(node);
3550+
var baseTypeNode = getClassExtendsHeritageClauseElement(node);
35513551
if (baseTypeNode) {
35523552
write(" extends ");
35533553
emit(baseTypeNode.expression);
@@ -3621,7 +3621,7 @@ module ts {
36213621
}
36223622

36233623
write("(function (");
3624-
let baseTypeNode = getClassBaseTypeNode(node);
3624+
let baseTypeNode = getClassExtendsHeritageClauseElement(node);
36253625
if (baseTypeNode) {
36263626
write("_super");
36273627
}

src/compiler/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,12 @@ module ts {
951951
node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier;
952952
}
953953

954-
export function getClassBaseTypeNode(node: ClassLikeDeclaration) {
954+
export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration) {
955955
let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword);
956956
return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
957957
}
958958

959-
export function getClassImplementedTypeNodes(node: ClassDeclaration) {
959+
export function getClassImplementsHeritageClauseElements(node: ClassDeclaration) {
960960
let heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ImplementsKeyword);
961961
return heritageClause ? heritageClause.types : undefined;
962962
}

src/services/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4948,8 +4948,8 @@ module ts {
49484948
if (symbol && symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
49494949
forEach(symbol.getDeclarations(), declaration => {
49504950
if (declaration.kind === SyntaxKind.ClassDeclaration) {
4951-
getPropertySymbolFromTypeReference(getClassBaseTypeNode(<ClassDeclaration>declaration));
4952-
forEach(getClassImplementedTypeNodes(<ClassDeclaration>declaration), getPropertySymbolFromTypeReference);
4951+
getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(<ClassDeclaration>declaration));
4952+
forEach(getClassImplementsHeritageClauseElements(<ClassDeclaration>declaration), getPropertySymbolFromTypeReference);
49534953
}
49544954
else if (declaration.kind === SyntaxKind.InterfaceDeclaration) {
49554955
forEach(getInterfaceBaseTypeNodes(<InterfaceDeclaration>declaration), getPropertySymbolFromTypeReference);

tests/baselines/reference/classExtendingPrimitive.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
44
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(6,18): error TS2304: Cannot find name 'Void'.
55
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(7,19): error TS1109: Expression expected.
66
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(8,18): error TS2304: Cannot find name 'Null'.
7-
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(9,19): error TS9002: Only type references are currently supported in a class 'extends' clauses.
7+
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(9,19): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.
88
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(10,18): error TS2304: Cannot find name 'undefined'.
99
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(11,18): error TS2304: Cannot find name 'Undefined'.
1010
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(14,18): error TS2311: A class may only extend another class.
@@ -33,7 +33,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
3333
!!! error TS2304: Cannot find name 'Null'.
3434
class C5a extends null { }
3535
~~~~
36-
!!! error TS9002: Only type references are currently supported in a class 'extends' clauses.
36+
!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.
3737
class C6 extends undefined { }
3838
~~~~~~~~~
3939
!!! error TS2304: Cannot find name 'undefined'.

tests/baselines/reference/classExtendingPrimitive2.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(3,19): error TS1109: Expression expected.
2-
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(4,19): error TS9002: Only type references are currently supported in a class 'extends' clauses.
2+
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts(4,19): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.
33

44

55
==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts (2 errors) ====
@@ -10,4 +10,4 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
1010
!!! error TS1109: Expression expected.
1111
class C5a extends null { }
1212
~~~~
13-
!!! error TS9002: Only type references are currently supported in a class 'extends' clauses.
13+
!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.

tests/baselines/reference/classExtendsEveryObjectType.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2311: A class may only extend another class.
2-
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS9002: Only type references are currently supported in a class 'extends' clauses.
2+
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.
33
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,31): error TS1005: ',' expected.
44
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(8,18): error TS2304: Cannot find name 'x'.
55
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(11,18): error TS2304: Cannot find name 'M'.
66
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(14,18): error TS2304: Cannot find name 'foo'.
7-
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS9002: Only type references are currently supported in a class 'extends' clauses.
7+
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(16,18): error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.
88

99

1010
==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts (7 errors) ====
@@ -17,7 +17,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
1717

1818
class C2 extends { foo: string; } { } // error
1919
~~~~~~~~~~~~~~~~
20-
!!! error TS9002: Only type references are currently supported in a class 'extends' clauses.
20+
!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.
2121
~
2222
!!! error TS1005: ',' expected.
2323
var x: { foo: string; }
@@ -37,4 +37,4 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
3737

3838
class C6 extends []{ } // error
3939
~~
40-
!!! error TS9002: Only type references are currently supported in a class 'extends' clauses.
40+
!!! error TS9002: Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.

0 commit comments

Comments
 (0)