mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Make isReferencedAliasDeclaration check children
This commit is contained in:
@@ -11220,13 +11220,18 @@ module ts {
|
||||
return isConstEnumSymbol(s) || s.constEnumOnlyModule;
|
||||
}
|
||||
|
||||
function isReferencedAliasDeclaration(node: Node): boolean {
|
||||
function isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean {
|
||||
if (isAliasSymbolDeclaration(node)) {
|
||||
let symbol = getSymbolOfNode(node);
|
||||
if (getSymbolLinks(symbol).referenced) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkChildren) {
|
||||
return forEachChild(node, node => isReferencedAliasDeclaration(node, checkChildren));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isImplementationOfOverload(node: FunctionLikeDeclaration) {
|
||||
|
||||
+4
-26
@@ -2717,7 +2717,7 @@ module ts {
|
||||
if (!(node.flags & NodeFlags.Export)) {
|
||||
emitStartOfVariableDeclarationList(node.declarationList);
|
||||
}
|
||||
else if (languageVersion >= ScriptTarget.ES6 && node.parent.kind === SyntaxKind.SourceFile) {
|
||||
else if (isES6ExportedDeclaration(node)) {
|
||||
// Exported ES6 module member
|
||||
write("export ");
|
||||
emitStartOfVariableDeclarationList(node.declarationList);
|
||||
@@ -3686,8 +3686,8 @@ module ts {
|
||||
|
||||
// ES6 import
|
||||
if (node.importClause) {
|
||||
let shouldEmitDefaultBindings = hasReferencedDefaultName(node.importClause);
|
||||
let shouldEmitNamedBindings = hasReferencedNamedBindings(node.importClause);
|
||||
let shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause);
|
||||
let shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true);
|
||||
if (shouldEmitDefaultBindings || shouldEmitNamedBindings) {
|
||||
write("import ");
|
||||
emitStart(node.importClause);
|
||||
@@ -3726,27 +3726,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function hasReferencedDefaultName(importClause: ImportClause) {
|
||||
// If the default import is used, the mark will be on the importClause,
|
||||
// as the alias declaration.
|
||||
// If there are other named bindings on the import clause, we will
|
||||
// will mark either the namedBindings(import * as n) or the NamedImport
|
||||
// in the case of import {a}
|
||||
return resolver.isReferencedAliasDeclaration(importClause);
|
||||
}
|
||||
|
||||
function hasReferencedNamedBindings(importClause: ImportClause) {
|
||||
if (importClause && importClause.namedBindings) {
|
||||
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
return resolver.isReferencedAliasDeclaration(importClause.namedBindings);
|
||||
}
|
||||
else {
|
||||
return forEach((<NamedImports>importClause.namedBindings).elements,
|
||||
namedImport => resolver.isReferencedAliasDeclaration(namedImport));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitExternalImportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration) {
|
||||
if (contains(externalImports, node)) {
|
||||
let isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0;
|
||||
@@ -3961,8 +3940,7 @@ module ts {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
if (!(<ImportDeclaration>node).importClause ||
|
||||
hasReferencedDefaultName((<ImportDeclaration>node).importClause) ||
|
||||
hasReferencedNamedBindings((<ImportDeclaration>node).importClause)) {
|
||||
resolver.isReferencedAliasDeclaration((<ImportDeclaration>node).importClause, /*checkChildren*/ true)) {
|
||||
// import "mod"
|
||||
// import x from "mod" where x is referenced
|
||||
// import * as x from "mod" where x is referenced
|
||||
|
||||
@@ -1207,7 +1207,7 @@ module ts {
|
||||
getGeneratedNameForNode(node: Node): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
|
||||
@@ -942,7 +942,7 @@ declare module "typescript" {
|
||||
getGeneratedNameForNode(node: Node): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
|
||||
@@ -3021,10 +3021,11 @@ declare module "typescript" {
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node) => boolean
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
>checkChildren : boolean
|
||||
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
>isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean
|
||||
|
||||
@@ -973,7 +973,7 @@ declare module "typescript" {
|
||||
getGeneratedNameForNode(node: Node): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
|
||||
@@ -3167,10 +3167,11 @@ declare module "typescript" {
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node) => boolean
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
>checkChildren : boolean
|
||||
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
>isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean
|
||||
|
||||
@@ -974,7 +974,7 @@ declare module "typescript" {
|
||||
getGeneratedNameForNode(node: Node): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
|
||||
@@ -3117,10 +3117,11 @@ declare module "typescript" {
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node) => boolean
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
>checkChildren : boolean
|
||||
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
>isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean
|
||||
|
||||
@@ -1011,7 +1011,7 @@ declare module "typescript" {
|
||||
getGeneratedNameForNode(node: Node): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
|
||||
@@ -3290,10 +3290,11 @@ declare module "typescript" {
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
isReferencedAliasDeclaration(node: Node): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node) => boolean
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
>isReferencedAliasDeclaration : (node: Node, checkChildren?: boolean) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
>checkChildren : boolean
|
||||
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
>isTopLevelValueImportEqualsWithEntityName : (node: ImportEqualsDeclaration) => boolean
|
||||
|
||||
Reference in New Issue
Block a user