Skip to content

Commit 0c5d736

Browse files
committed
Respond to code review remarks
1 parent 383f01d commit 0c5d736

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ module ts {
351351
}
352352
else if (location.kind === SyntaxKind.SourceFile) {
353353
result = getSymbol(getSymbolOfNode(location).exports, "default", meaning & SymbolFlags.ModuleMember);
354-
if (result && (result.flags & meaning) && result.valueDeclaration && (result.valueDeclaration.flags & NodeFlags.Default) && result.valueDeclaration.localSymbol.name === name) {
354+
let localSymbol = getLocalSymbolForExportDefault(result);
355+
if (result && (result.flags & meaning) && localSymbol && localSymbol.name === name) {
355356
break loop;
356357
}
357358
result = undefined;

src/compiler/utilities.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ module ts {
145145

146146
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
147147
}
148-
148+
149149
export function nodeIsPresent(node: Node) {
150150
return !nodeIsMissing(node);
151151
}
@@ -288,7 +288,7 @@ module ts {
288288
errorNode = (<Declaration>node).name;
289289
break;
290290
}
291-
291+
292292
if (errorNode === undefined) {
293293
// If we don't have a better node, then just set the error on the first token of
294294
// construct.
@@ -634,7 +634,7 @@ module ts {
634634

635635
return false;
636636
}
637-
637+
638638
export function childIsDecorated(node: Node): boolean {
639639
switch (node.kind) {
640640
case SyntaxKind.ClassDeclaration:
@@ -745,7 +745,7 @@ module ts {
745745
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
746746
let moduleState = getModuleInstanceState(node)
747747
return moduleState === ModuleInstanceState.Instantiated ||
748-
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
748+
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
749749
}
750750

751751
export function isExternalModuleImportEqualsDeclaration(node: Node) {
@@ -1161,7 +1161,7 @@ module ts {
11611161
export function createTextSpanFromBounds(start: number, end: number) {
11621162
return createTextSpan(start, end - start);
11631163
}
1164-
1164+
11651165
export function textChangeRangeNewSpan(range: TextChangeRange) {
11661166
return createTextSpan(range.span.start, range.newLength);
11671167
}
@@ -1435,13 +1435,13 @@ module ts {
14351435
return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0));
14361436
}
14371437
}
1438-
1438+
14391439
function get16BitUnicodeEscapeSequence(charCode: number): string {
14401440
let hexCharCode = charCode.toString(16).toUpperCase();
14411441
let paddedHexCode = ("0000" + hexCharCode).slice(-4);
14421442
return "\\u" + paddedHexCode;
14431443
}
1444-
1444+
14451445
let nonAsciiCharacters = /[^\u0000-\u007F]/g;
14461446
export function escapeNonAsciiCharacters(s: string): string {
14471447
// Replace non-ASCII characters with '\uNNNN' escapes if any exist.
@@ -1768,4 +1768,7 @@ module ts {
17681768
}
17691769
}
17701770

1771+
export function getLocalSymbolForExportDefault(symbol: Symbol) {
1772+
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
1773+
}
17711774
}

src/services/services.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,8 +2405,11 @@ module ts {
24052405
}
24062406

24072407
// If this is the default export, get the name of the declaration if it exists
2408-
if (displayName === "default" && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) && symbol.valueDeclaration.localSymbol && symbol.valueDeclaration.localSymbol.name) {
2409-
displayName = symbol.valueDeclaration.localSymbol.name;
2408+
if (displayName === "default") {
2409+
let localSymbol = getLocalSymbolForExportDefault(symbol);
2410+
if (localSymbol && localSymbol.name) {
2411+
displayName = symbol.valueDeclaration.localSymbol.name;
2412+
}
24102413
}
24112414

24122415
let firstCharCode = displayName.charCodeAt(0);

0 commit comments

Comments
 (0)