Merge pull request #10345 from Microsoft/meaning
Use an enum in checkClassForDuplicateDeclarations to make it prettier
This commit is contained in:
commit
7ee05ba809
1 changed files with 12 additions and 8 deletions
|
@ -13794,15 +13794,19 @@ namespace ts {
|
|||
}
|
||||
|
||||
function checkClassForDuplicateDeclarations(node: ClassLikeDeclaration) {
|
||||
const getter = 1, setter = 2, property = getter | setter;
|
||||
const enum Accessor {
|
||||
Getter = 1,
|
||||
Setter = 2,
|
||||
Property = Getter | Setter
|
||||
}
|
||||
|
||||
const instanceNames = createMap<number>();
|
||||
const staticNames = createMap<number>();
|
||||
const instanceNames = createMap<Accessor>();
|
||||
const staticNames = createMap<Accessor>();
|
||||
for (const member of node.members) {
|
||||
if (member.kind === SyntaxKind.Constructor) {
|
||||
for (const param of (member as ConstructorDeclaration).parameters) {
|
||||
if (isParameterPropertyDeclaration(param)) {
|
||||
addName(instanceNames, param.name, (param.name as Identifier).text, property);
|
||||
addName(instanceNames, param.name, (param.name as Identifier).text, Accessor.Property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13814,22 +13818,22 @@ namespace ts {
|
|||
if (memberName) {
|
||||
switch (member.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
addName(names, member.name, memberName, getter);
|
||||
addName(names, member.name, memberName, Accessor.Getter);
|
||||
break;
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
addName(names, member.name, memberName, setter);
|
||||
addName(names, member.name, memberName, Accessor.Setter);
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
addName(names, member.name, memberName, property);
|
||||
addName(names, member.name, memberName, Accessor.Property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addName(names: Map<number>, location: Node, name: string, meaning: number) {
|
||||
function addName(names: Map<Accessor>, location: Node, name: string, meaning: Accessor) {
|
||||
const prev = names[name];
|
||||
if (prev) {
|
||||
if (prev & meaning) {
|
||||
|
|
Loading…
Reference in a new issue