Skip to content

Commit 3d9c920

Browse files
committed
Code review comments
1 parent 8fb3b25 commit 3d9c920

2 files changed

Lines changed: 31 additions & 31 deletions

File tree

src/compiler/checker.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ namespace ts {
901901
}
902902

903903
if (result && noUnusedIdentifiers && !isInAmbientContext(location)) {
904-
result.hasReference = true;
904+
result.isReferenced = true;
905905
}
906906
}
907907
return result;
@@ -10242,7 +10242,7 @@ namespace ts {
1024210242
}
1024310243

1024410244
if (noUnusedIdentifiers && !isInAmbientContext(node)) {
10245-
prop.hasReference = true;
10245+
prop.isReferenced = true;
1024610246
}
1024710247

1024810248
getNodeLinks(node).resolvedSymbol = prop;
@@ -12187,7 +12187,7 @@ namespace ts {
1218712187
}
1218812188
}
1218912189
}
12190-
checkUnusedIdentifiersDeferred(node);
12190+
registerForUnusedIdentifiersCheck(node);
1219112191
}
1219212192
}
1219312193

@@ -13415,7 +13415,7 @@ namespace ts {
1341513415
checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node);
1341613416

1341713417
checkSourceElement(node.body);
13418-
checkUnusedIdentifiersDeferred(node);
13418+
registerForUnusedIdentifiersCheck(node);
1341913419

1342013420
const symbol = getSymbolOfNode(node);
1342113421
const firstDeclaration = getDeclarationOfKind(symbol, node.kind);
@@ -13561,7 +13561,7 @@ namespace ts {
1356113561
}
1356213562
if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) {
1356313563
checkSourceElement(node.body);
13564-
checkUnusedIdentifiersDeferred(node);
13564+
registerForUnusedIdentifiersCheck(node);
1356513565
}
1356613566
else {
1356713567
checkNodeDeferred(node);
@@ -13578,7 +13578,7 @@ namespace ts {
1357813578

1357913579
function checkAccessorDeferred(node: AccessorDeclaration) {
1358013580
checkSourceElement(node.body);
13581-
checkUnusedIdentifiersDeferred(node);
13581+
registerForUnusedIdentifiersCheck(node);
1358213582
}
1358313583

1358413584
function checkMissingDeclaration(node: Node) {
@@ -14482,26 +14482,26 @@ namespace ts {
1448214482
}
1448314483
}
1448414484

14485-
checkUnusedIdentifiersDeferred(node);
14485+
registerForUnusedIdentifiersCheck(node);
1448614486
}
1448714487

14488-
function checkUnusedIdentifiersDeferred(node: Node) {
14488+
function registerForUnusedIdentifiersCheck(node: Node) {
1448914489
if (deferredUnusedIdentifierNodes) {
1449014490
deferredUnusedIdentifierNodes.push(node);
1449114491
}
1449214492
}
1449314493

14494-
function checkUnusedIdentifiersDeferredNodes() {
14494+
function checkUnusedIdentifiers() {
1449514495
if (deferredUnusedIdentifierNodes) {
1449614496
for (const node of deferredUnusedIdentifierNodes) {
1449714497
switch (node.kind) {
1449814498
case SyntaxKind.SourceFile:
1449914499
case SyntaxKind.ModuleDeclaration:
14500-
checkUnusedModuleLocals(<ModuleDeclaration | SourceFile>node);
14500+
checkUnusedModuleMembers(<ModuleDeclaration | SourceFile>node);
1450114501
break;
1450214502
case SyntaxKind.ClassDeclaration:
1450314503
case SyntaxKind.ClassExpression:
14504-
checkUnusedClassLocals(<ClassDeclaration | ClassExpression>node);
14504+
checkUnusedClassMembers(<ClassDeclaration | ClassExpression>node);
1450514505
checkUnusedTypeParameters(<ClassDeclaration | ClassExpression>node);
1450614506
break;
1450714507
case SyntaxKind.InterfaceDeclaration:
@@ -14511,7 +14511,7 @@ namespace ts {
1451114511
case SyntaxKind.ForStatement:
1451214512
case SyntaxKind.ForInStatement:
1451314513
case SyntaxKind.ForOfStatement:
14514-
checkUnusedIdentifiers(<Block | ForInStatement | ForStatement | ForOfStatement>node);
14514+
checkUnusedLocalsAndParameters(<Block | ForInStatement | ForStatement | ForOfStatement>node);
1451514515
break;
1451614516
case SyntaxKind.Constructor:
1451714517
case SyntaxKind.FunctionExpression:
@@ -14521,7 +14521,7 @@ namespace ts {
1452114521
case SyntaxKind.GetAccessor:
1452214522
case SyntaxKind.SetAccessor:
1452314523
if ((<FunctionLikeDeclaration>node).body) {
14524-
checkUnusedIdentifiers(<FunctionLikeDeclaration>node);
14524+
checkUnusedLocalsAndParameters(<FunctionLikeDeclaration>node);
1452514525
}
1452614526
checkUnusedTypeParameters(<FunctionLikeDeclaration>node);
1452714527
break;
@@ -14538,12 +14538,12 @@ namespace ts {
1453814538
}
1453914539
}
1454014540

14541-
function checkUnusedIdentifiers(node: FunctionLikeDeclaration | ForStatement | Block): void {
14541+
function checkUnusedLocalsAndParameters(node: FunctionLikeDeclaration | ForStatement | Block): void {
1454214542
if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) {
1454314543
for (const key in node.locals) {
1454414544
if (hasProperty(node.locals, key)) {
1454514545
const local = node.locals[key];
14546-
if (!local.hasReference) {
14546+
if (!local.isReferenced) {
1454714547
if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) {
1454814548
if (compilerOptions.noUnusedParameters && !isParameterPropertyDeclaration(<ParameterDeclaration>local.valueDeclaration)) {
1454914549
error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
@@ -14558,18 +14558,18 @@ namespace ts {
1455814558
}
1455914559
}
1456014560

14561-
function checkUnusedClassLocals(node: ClassDeclaration | ClassExpression): void {
14561+
function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void {
1456214562
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
1456314563
if (node.members) {
1456414564
for (const member of node.members) {
1456514565
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) {
14566-
if (isPrivateNode(member) && !member.symbol.hasReference) {
14566+
if (isPrivateNode(member) && !member.symbol.isReferenced) {
1456714567
error(member.name, Diagnostics._0_is_declared_but_never_used, member.symbol.name);
1456814568
}
1456914569
}
1457014570
else if (member.kind === SyntaxKind.Constructor) {
1457114571
for (const parameter of (<ConstructorDeclaration>member).parameters) {
14572-
if (isPrivateNode(parameter) && !parameter.symbol.hasReference) {
14572+
if (isPrivateNode(parameter) && !parameter.symbol.isReferenced) {
1457314573
error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name);
1457414574
}
1457514575
}
@@ -14583,7 +14583,7 @@ namespace ts {
1458314583
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
1458414584
if (node.typeParameters) {
1458514585
for (const typeParameter of node.typeParameters) {
14586-
if (!typeParameter.symbol.hasReference) {
14586+
if (!typeParameter.symbol.isReferenced) {
1458714587
error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
1458814588
}
1458914589
}
@@ -14595,12 +14595,12 @@ namespace ts {
1459514595
return (node.flags & NodeFlags.Private) !== 0;
1459614596
}
1459714597

14598-
function checkUnusedModuleLocals(node: ModuleDeclaration | SourceFile): void {
14598+
function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void {
1459914599
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
1460014600
for (const key in node.locals) {
1460114601
if (hasProperty(node.locals, key)) {
1460214602
const local = node.locals[key];
14603-
if (!local.hasReference && !local.exportSymbol) {
14603+
if (!local.isReferenced && !local.exportSymbol) {
1460414604
for (const declaration of local.declarations) {
1460514605
if (!isAmbientModule(declaration)) {
1460614606
error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name);
@@ -14619,7 +14619,7 @@ namespace ts {
1461914619
}
1462014620
forEach(node.statements, checkSourceElement);
1462114621
if (node.locals) {
14622-
checkUnusedIdentifiersDeferred(node);
14622+
registerForUnusedIdentifiersCheck(node);
1462314623
}
1462414624
}
1462514625

@@ -15085,7 +15085,7 @@ namespace ts {
1508515085
if (node.condition) checkExpression(node.condition);
1508615086
if (node.incrementor) checkExpression(node.incrementor);
1508715087
checkSourceElement(node.statement);
15088-
checkUnusedIdentifiersDeferred(node);
15088+
registerForUnusedIdentifiersCheck(node);
1508915089
}
1509015090

1509115091
function checkForOfStatement(node: ForOfStatement): void {
@@ -15127,7 +15127,7 @@ namespace ts {
1512715127

1512815128
checkSourceElement(node.statement);
1512915129
if (node.locals) {
15130-
checkUnusedIdentifiersDeferred(node);
15130+
registerForUnusedIdentifiersCheck(node);
1513115131
}
1513215132
}
1513315133

@@ -15177,7 +15177,7 @@ namespace ts {
1517715177

1517815178
checkSourceElement(node.statement);
1517915179
if (node.locals) {
15180-
checkUnusedIdentifiersDeferred(node);
15180+
registerForUnusedIdentifiersCheck(node);
1518115181
}
1518215182
}
1518315183

@@ -15771,7 +15771,7 @@ namespace ts {
1577115771

1577215772
function checkClassExpressionDeferred(node: ClassExpression) {
1577315773
forEach(node.members, checkSourceElement);
15774-
checkUnusedIdentifiersDeferred(node);
15774+
registerForUnusedIdentifiersCheck(node);
1577515775
}
1577615776

1577715777
function checkClassDeclaration(node: ClassDeclaration) {
@@ -15781,7 +15781,7 @@ namespace ts {
1578115781
checkClassLikeDeclaration(node);
1578215782
forEach(node.members, checkSourceElement);
1578315783

15784-
checkUnusedIdentifiersDeferred(node);
15784+
registerForUnusedIdentifiersCheck(node);
1578515785
}
1578615786

1578715787
function checkClassLikeDeclaration(node: ClassLikeDeclaration) {
@@ -16489,7 +16489,7 @@ namespace ts {
1648916489
if (node.body) {
1649016490
checkSourceElement(node.body);
1649116491
if (!isGlobalScopeAugmentation(node)) {
16492-
checkUnusedIdentifiersDeferred(node);
16492+
registerForUnusedIdentifiersCheck(node);
1649316493
}
1649416494
}
1649516495
}
@@ -17019,11 +17019,11 @@ namespace ts {
1701917019
checkDeferredNodes();
1702017020

1702117021
if (isExternalModule(node)) {
17022-
checkUnusedIdentifiersDeferred(node);
17022+
registerForUnusedIdentifiersCheck(node);
1702317023
}
1702417024

1702517025
if (!node.isDeclarationFile) {
17026-
checkUnusedIdentifiersDeferredNodes();
17026+
checkUnusedIdentifiers();
1702717027
}
1702817028

1702917029
deferredNodes = undefined;

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ namespace ts {
21282128
/* @internal */ parent?: Symbol; // Parent symbol
21292129
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
21302130
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
2131-
/* @internal */ hasReference?: boolean; // True if the symbol is referenced elsewhere
2131+
/* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere
21322132
}
21332133

21342134
/* @internal */

0 commit comments

Comments
 (0)