Skip to content

Commit 356651e

Browse files
committed
Address comments: simplify, dedupe and clean up
1 parent 9983a11 commit 356651e

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18091,18 +18091,17 @@ namespace ts {
1809118091

1809218092
forEach(overloads, o => {
1809318093
const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags;
18094-
const name = getNameOfDeclaration(o);
1809518094
if (deviation & ModifierFlags.Export) {
18096-
error(name, Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
18095+
error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
1809718096
}
1809818097
else if (deviation & ModifierFlags.Ambient) {
18099-
error(name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
18098+
error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
1810018099
}
1810118100
else if (deviation & (ModifierFlags.Private | ModifierFlags.Protected)) {
18102-
error(name || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
18101+
error(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
1810318102
}
1810418103
else if (deviation & ModifierFlags.Abstract) {
18105-
error(name, Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
18104+
error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
1810618105
}
1810718106
});
1810818107
}
@@ -20240,17 +20239,9 @@ namespace ts {
2024020239
return;
2024120240
}
2024220241

20243-
let errorNode: Node;
20244-
if (propDeclaration && propDeclaration.kind === SyntaxKind.BinaryExpression) {
20245-
const specialAssignmentKind = getSpecialPropertyAssignmentKind(propDeclaration as BinaryExpression);
20246-
if (specialAssignmentKind === SpecialPropertyAssignmentKind.Property ||
20247-
specialAssignmentKind === SpecialPropertyAssignmentKind.PrototypeProperty ||
20248-
specialAssignmentKind === SpecialPropertyAssignmentKind.ThisProperty) {
20249-
errorNode = propDeclaration;
20250-
}
20251-
}
2025220242
// perform property check if property or indexer is declared in 'type'
20253-
// this allows to rule out cases when both property and indexer are inherited from the base class
20243+
// this allows us to rule out cases when both property and indexer are inherited from the base class
20244+
let errorNode: Node;
2025420245
if (propDeclaration &&
2025520246
(propDeclaration.kind === SyntaxKind.BinaryExpression ||
2025620247
getNameOfDeclaration(propDeclaration).kind === SyntaxKind.ComputedPropertyName ||

src/compiler/utilities.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,21 +1781,21 @@ namespace ts {
17811781
const kind = getSpecialPropertyAssignmentKind(declaration);
17821782
const lhs = (declaration as BinaryExpression).left;
17831783
switch (kind) {
1784-
case SpecialPropertyAssignmentKind.None:
1785-
case SpecialPropertyAssignmentKind.ModuleExports:
1786-
return undefined;
1787-
case SpecialPropertyAssignmentKind.ExportsProperty:
1788-
if (lhs.kind === SyntaxKind.Identifier) {
1784+
case SpecialPropertyAssignmentKind.None:
1785+
case SpecialPropertyAssignmentKind.ModuleExports:
1786+
return undefined;
1787+
case SpecialPropertyAssignmentKind.ExportsProperty:
1788+
if (lhs.kind === SyntaxKind.Identifier) {
1789+
return (lhs as PropertyAccessExpression).name;
1790+
}
1791+
else {
1792+
return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name;
1793+
}
1794+
case SpecialPropertyAssignmentKind.ThisProperty:
1795+
case SpecialPropertyAssignmentKind.Property:
17891796
return (lhs as PropertyAccessExpression).name;
1790-
}
1791-
else {
1797+
case SpecialPropertyAssignmentKind.PrototypeProperty:
17921798
return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name;
1793-
}
1794-
case SpecialPropertyAssignmentKind.ThisProperty:
1795-
case SpecialPropertyAssignmentKind.Property:
1796-
return (lhs as PropertyAccessExpression).name;
1797-
case SpecialPropertyAssignmentKind.PrototypeProperty:
1798-
return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name;
17991799
}
18001800
}
18011801
else {
@@ -2022,7 +2022,8 @@ namespace ts {
20222022
* Symbol.
20232023
*/
20242024
export function hasDynamicName(declaration: Declaration): boolean {
2025-
return getNameOfDeclaration(declaration) && isDynamicName(getNameOfDeclaration(declaration));
2025+
const name = getNameOfDeclaration(declaration);
2026+
return name && isDynamicName(name);
20262027
}
20272028

20282029
export function isDynamicName(name: DeclarationName): boolean {

0 commit comments

Comments
 (0)