Added BindingElement to isSomeImportDeclaration (#43387)

* Added BindingElement to isSomeImportDeclaration

* Added tests

* Refactores to use getDeclarationOfAlias
This commit is contained in:
Armando Aguirre
2021-03-31 18:18:16 -07:00
committed by GitHub
parent 62f3ccd9c0
commit 8f8a579eee
4 changed files with 61 additions and 16 deletions

View File

@@ -2489,6 +2489,7 @@ namespace ts {
* module.exports = <EntityNameExpression>
* {<Identifier>}
* {name: <EntityNameExpression>}
* const { x } = require ...
*/
function isAliasSymbolDeclaration(node: Node): boolean {
return node.kind === SyntaxKind.ImportEqualsDeclaration
@@ -23933,7 +23934,7 @@ namespace ts {
}
}
else if (isAlias) {
declaration = symbol.declarations?.find(isSomeImportDeclaration);
declaration = getDeclarationOfAliasSymbol(symbol);
}
else {
return type;
@@ -41950,21 +41951,6 @@ namespace ts {
}
}
function isSomeImportDeclaration(decl: Node): boolean {
switch (decl.kind) {
case SyntaxKind.ImportClause: // For default import
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.NamespaceImport:
case SyntaxKind.ImportSpecifier: // For rename import `x as y`
return true;
case SyntaxKind.Identifier:
// For regular import, `decl` is an Identifier under the ImportSpecifier.
return decl.parent.kind === SyntaxKind.ImportSpecifier;
default:
return false;
}
}
namespace JsxNames {
export const JSX = "JSX" as __String;
export const IntrinsicElements = "IntrinsicElements" as __String;