mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-19 12:45:58 -05:00
Added BindingElement to isSomeImportDeclaration (#43387)
* Added BindingElement to isSomeImportDeclaration * Added tests * Refactores to use getDeclarationOfAlias
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user