mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 04:17:34 -06:00
Address review comments
1. Give class name in error message. 2. Reduce nesting via an early exit.
This commit is contained in:
parent
0d3f6473cf
commit
14a457e518
@ -14033,16 +14033,17 @@ namespace ts {
|
||||
|
||||
/** Check that type parameter lists are identical across multiple declarations */
|
||||
function checkTypeParameterListsIdentical(node: ClassLikeDeclaration | InterfaceDeclaration, symbol: Symbol) {
|
||||
if (symbol.declarations.length === 1) {
|
||||
return;
|
||||
}
|
||||
let firstDecl: ClassLikeDeclaration | InterfaceDeclaration;
|
||||
if (symbol.declarations.length > 1) {
|
||||
for (const declaration of symbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
if (!firstDecl) {
|
||||
firstDecl = <ClassLikeDeclaration | InterfaceDeclaration>declaration;
|
||||
}
|
||||
else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) {
|
||||
error(node.name, Diagnostics.All_declarations_must_have_identical_type_parameters);
|
||||
}
|
||||
for (const declaration of symbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
if (!firstDecl) {
|
||||
firstDecl = <ClassLikeDeclaration | InterfaceDeclaration>declaration;
|
||||
}
|
||||
else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) {
|
||||
error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1311,7 +1311,7 @@
|
||||
"category": "Error",
|
||||
"code": 2427
|
||||
},
|
||||
"All declarations must have identical type parameters.": {
|
||||
"All declarations of '{0}' must have identical type parameters.": {
|
||||
"category": "Error",
|
||||
"code": 2428
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user