| 1234567891011121314151617181920212223242526272829303132333435 |
- "use strict";
- /**
- * @license
- * Copyright Google LLC All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- const ts = require("typescript");
- /** Gets import information about the specified identifier by using the type checker. */
- function getImportOfIdentifier(typeChecker, node) {
- const symbol = typeChecker.getSymbolAtLocation(node);
- if (!symbol || !symbol.declarations.length) {
- return null;
- }
- const decl = symbol.declarations[0];
- if (!ts.isImportSpecifier(decl)) {
- return null;
- }
- // Since "decl" is an import specifier, we can walk up three times to get a reference
- // to the import declaration node (NamedImports -> ImportClause -> ImportDeclaration).
- const importDecl = decl.parent.parent.parent;
- if (!ts.isStringLiteral(importDecl.moduleSpecifier)) {
- return null;
- }
- return {
- // Handles aliased imports: e.g. "import {Component as myComp} from ...";
- name: decl.propertyName ? decl.propertyName.text : decl.name.text,
- importModule: importDecl.moduleSpecifier.text,
- node: importDecl
- };
- }
- exports.getImportOfIdentifier = getImportOfIdentifier;
- //# sourceMappingURL=imports.js.map
|