Address comments: simplify, dedupe and clean up
This commit is contained in:
parent
b39c319f0c
commit
6a175321bf
2 changed files with 23 additions and 30 deletions
|
@ -18110,18 +18110,17 @@ namespace ts {
|
|||
|
||||
forEach(overloads, o => {
|
||||
const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags;
|
||||
const name = getNameOfDeclaration(o);
|
||||
if (deviation & ModifierFlags.Export) {
|
||||
error(name, Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
|
||||
error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
|
||||
}
|
||||
else if (deviation & ModifierFlags.Ambient) {
|
||||
error(name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
|
||||
error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
|
||||
}
|
||||
else if (deviation & (ModifierFlags.Private | ModifierFlags.Protected)) {
|
||||
error(name || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
|
||||
error(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
|
||||
}
|
||||
else if (deviation & ModifierFlags.Abstract) {
|
||||
error(name, Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
|
||||
error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -20317,19 +20316,12 @@ namespace ts {
|
|||
return;
|
||||
}
|
||||
|
||||
let errorNode: Node;
|
||||
if (propDeclaration && propDeclaration.kind === SyntaxKind.BinaryExpression) {
|
||||
const specialAssignmentKind = getSpecialPropertyAssignmentKind(propDeclaration as BinaryExpression);
|
||||
if (specialAssignmentKind === SpecialPropertyAssignmentKind.Property ||
|
||||
specialAssignmentKind === SpecialPropertyAssignmentKind.PrototypeProperty ||
|
||||
specialAssignmentKind === SpecialPropertyAssignmentKind.ThisProperty) {
|
||||
errorNode = propDeclaration;
|
||||
}
|
||||
}
|
||||
// perform property check if property or indexer is declared in 'type'
|
||||
// this allows to rule out cases when both property and indexer are inherited from the base class
|
||||
// this allows us to rule out cases when both property and indexer are inherited from the base class
|
||||
let errorNode: Node;
|
||||
if (propDeclaration &&
|
||||
(getNameOfDeclaration(propDeclaration).kind === SyntaxKind.ComputedPropertyName ||
|
||||
(propDeclaration.kind === SyntaxKind.BinaryExpression ||
|
||||
getNameOfDeclaration(propDeclaration).kind === SyntaxKind.ComputedPropertyName ||
|
||||
prop.parent === containingType.symbol)) {
|
||||
errorNode = propDeclaration;
|
||||
}
|
||||
|
|
|
@ -1784,21 +1784,21 @@ namespace ts {
|
|||
const kind = getSpecialPropertyAssignmentKind(declaration);
|
||||
const lhs = (declaration as BinaryExpression).left;
|
||||
switch (kind) {
|
||||
case SpecialPropertyAssignmentKind.None:
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
return undefined;
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
if (lhs.kind === SyntaxKind.Identifier) {
|
||||
case SpecialPropertyAssignmentKind.None:
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
return undefined;
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
if (lhs.kind === SyntaxKind.Identifier) {
|
||||
return (lhs as PropertyAccessExpression).name;
|
||||
}
|
||||
else {
|
||||
return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name;
|
||||
}
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
return (lhs as PropertyAccessExpression).name;
|
||||
}
|
||||
else {
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name;
|
||||
}
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
return (lhs as PropertyAccessExpression).name;
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -2025,7 +2025,8 @@ namespace ts {
|
|||
* Symbol.
|
||||
*/
|
||||
export function hasDynamicName(declaration: Declaration): boolean {
|
||||
return getNameOfDeclaration(declaration) && isDynamicName(getNameOfDeclaration(declaration));
|
||||
const name = getNameOfDeclaration(declaration);
|
||||
return name && isDynamicName(name);
|
||||
}
|
||||
|
||||
export function isDynamicName(name: DeclarationName): boolean {
|
||||
|
|
Loading…
Reference in a new issue