importedNames
uses tcmts.core.ts.parse, which uses tcmts.core.ts.compiler, which uses process
The names a file's imports bind.
import { parse } from "#codebase/tcmts/core/ts"; import { isImportDeclaration as ts_isImportDeclaration, isNamespaceImport as ts_isNamespaceImport, } from "typescript/ast"; export function importedNames(file: string, text: string): string[] { const out: string[] = []; for (const st of parse(file, text).statements) { const c = ts_isImportDeclaration(st) ? st.importClause : undefined; if (!c) continue; if (c.name) out.push(c.name.text); const b = c.namedBindings; if (b && ts_isNamespaceImport(b)) out.push(b.name.text); else if (b) for (const e of b.elements) out.push(e.name.text); } return out; }