Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 573040f

Browse filesBrowse files
committed
Convert Declaration to union, not type hierarchy
1 parent aceadeb commit 573040f
Copy full SHA for 573040f

File tree

Expand file treeCollapse file tree

5 files changed

+191
-88
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+191
-88
lines changed

‎src/compiler/binder.ts

Copy file name to clipboardExpand all lines: src/compiler/binder.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ namespace ts {
304304
}
305305

306306
function getDisplayName(node: Declaration): string {
307-
return (node as RealDeclaration).name ? declarationNameToString((node as RealDeclaration).name) : getDeclarationName(node);
307+
return (node as DeclarationBase).name ? declarationNameToString((node as DeclarationBase).name) : getDeclarationName(node);
308308
}
309309

310310
/**
@@ -367,8 +367,8 @@ namespace ts {
367367
symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name));
368368
}
369369
else {
370-
if ((node as RealDeclaration).name) {
371-
(node as RealDeclaration).name.parent = node;
370+
if ((node as DeclarationBase).name) {
371+
(node as DeclarationBase).name.parent = node;
372372
}
373373

374374
// Report errors every position with duplicate declaration

‎src/compiler/checker.ts

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,7 +3621,7 @@ namespace ts {
36213621
});
36223622
}
36233623

3624-
function isDeclarationVisible(node: Declaration): boolean {
3624+
function isDeclarationVisible(node: Node): boolean {
36253625
if (node) {
36263626
const links = getNodeLinks(node);
36273627
if (links.isVisible === undefined) {
@@ -3635,10 +3635,10 @@ namespace ts {
36353635
function determineIfDeclarationIsVisible() {
36363636
switch (node.kind) {
36373637
case SyntaxKind.BindingElement:
3638-
return isDeclarationVisible(<Declaration>node.parent.parent);
3638+
return isDeclarationVisible(node.parent.parent);
36393639
case SyntaxKind.VariableDeclaration:
3640-
if (isBindingPattern(node.name) &&
3641-
!(<BindingPattern>node.name).elements.length) {
3640+
const declaration = node as VariableDeclaration;
3641+
if (isBindingPattern(declaration.name) && !declaration.name.elements.length) {
36423642
// If the binding pattern is empty, this variable declaration is not visible
36433643
return false;
36443644
}
@@ -3661,7 +3661,7 @@ namespace ts {
36613661
return isGlobalSourceFile(parent);
36623662
}
36633663
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
3664-
return isDeclarationVisible(<Declaration>parent);
3664+
return isDeclarationVisible(parent);
36653665

36663666
case SyntaxKind.PropertyDeclaration:
36673667
case SyntaxKind.PropertySignature:
@@ -3691,7 +3691,7 @@ namespace ts {
36913691
case SyntaxKind.UnionType:
36923692
case SyntaxKind.IntersectionType:
36933693
case SyntaxKind.ParenthesizedType:
3694-
return isDeclarationVisible(<Declaration>node.parent);
3694+
return isDeclarationVisible(node.parent);
36953695

36963696
// Default binding, import specifier and namespace import is visible
36973697
// only on demand so by default it is not visible
@@ -6236,8 +6236,8 @@ namespace ts {
62366236
case SyntaxKind.MethodDeclaration:
62376237
case SyntaxKind.GetAccessor:
62386238
case SyntaxKind.SetAccessor:
6239-
return (<RealDeclaration>node).name.kind === SyntaxKind.ComputedPropertyName
6240-
&& traverse((<RealDeclaration>node).name);
6239+
return (<DeclarationBase>node).name.kind === SyntaxKind.ComputedPropertyName
6240+
&& traverse((<DeclarationBase>node).name);
62416241

62426242
default:
62436243
return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && forEachChild(node, traverse);
@@ -21917,7 +21917,7 @@ namespace ts {
2191721917
function isTypeDeclarationName(name: Node): boolean {
2191821918
return name.kind === SyntaxKind.Identifier &&
2191921919
isTypeDeclaration(name.parent) &&
21920-
(<RealDeclaration>name.parent).name === name;
21920+
(<TypeElement>name.parent).name === name;
2192121921
}
2192221922

2192321923
function isTypeDeclaration(node: Node): boolean {
@@ -22545,7 +22545,7 @@ namespace ts {
2254522545

2254622546
// Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an
2254722547
// existing name or might hide a name when compiled downlevel
22548-
function isDeclarationWithCollidingName(node: Declaration): boolean {
22548+
function isDeclarationWithCollidingName(node: Node): boolean {
2254922549
node = getParseTreeNode(node, isDeclaration);
2255022550
if (node) {
2255122551
const symbol = getSymbolOfNode(node);

‎src/compiler/transformers/es2015.ts

Copy file name to clipboardExpand all lines: src/compiler/transformers/es2015.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3748,7 +3748,7 @@ namespace ts {
37483748
case SyntaxKind.ClassDeclaration:
37493749
case SyntaxKind.EnumDeclaration:
37503750
case SyntaxKind.VariableDeclaration:
3751-
return (<RealDeclaration>parent).name === node
3751+
return (<DeclarationBase>parent).name === node
37523752
&& resolver.isDeclarationWithCollidingName(<Declaration>parent);
37533753
}
37543754

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.