Skip to content

Commit 06c9876

Browse files
author
Yui T
committed
Address code review
1 parent 2e0c390 commit 06c9876

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/compiler/checker.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -12686,10 +12686,7 @@ namespace ts {
1268612686
// we will add the symbol into the table using its declared name
1268712687
let name = (<FunctionExpression|ClassExpression>location).name;
1268812688
if (name) {
12689-
let symbol = location.symbol;
12690-
if (symbol.flags & meaning && !hasProperty(symbols, name.text)) {
12691-
symbols[name.text] = symbol;
12692-
}
12689+
copySymbol(location.symbol, meaning, name.text);
1269312690
}
1269412691
break;
1269512692
}
@@ -12701,11 +12698,18 @@ namespace ts {
1270112698
copySymbols(globals, meaning);
1270212699
}
1270312700

12704-
// Returns 'true' if we should stop processing symbols.
12705-
function copySymbol(symbol: Symbol, meaning: SymbolFlags): void {
12701+
/**
12702+
* Copy the given symbol into symbol tables if the symbol has the given meaning
12703+
* and it doesn't already existed in the symbol table
12704+
*
12705+
* @param symbol the symbol to be added into symbol table
12706+
* @param meaning meaning of symbol to filter by before adding to symbol table
12707+
* @param key a key for storing in symbol table; if null, use symbol.name
12708+
*/
12709+
function copySymbol(symbol: Symbol, meaning: SymbolFlags, key?: string): void {
1270612710
if (symbol.flags & meaning) {
12707-
let id = symbol.name;
12708-
if (!isReservedMemberName(id) && !hasProperty(symbols, id)) {
12711+
let id = key || symbol.name;
12712+
if (!hasProperty(symbols, id)) {
1270912713
symbols[id] = symbol;
1271012714
}
1271112715
}
@@ -12714,9 +12718,7 @@ namespace ts {
1271412718
function copySymbols(source: SymbolTable, meaning: SymbolFlags): void {
1271512719
if (meaning) {
1271612720
for (let id in source) {
12717-
if (hasProperty(source, id)) {
12718-
copySymbol(source[id], meaning);
12719-
}
12721+
copySymbol(source[id], meaning);
1272012722
}
1272112723
}
1272212724
}

0 commit comments

Comments
 (0)