ast-transpiler is a versatile source-to-source transpiler that converts code between JavaScript, TypeScript, Python, and PHP by operating on abstract syntax trees. Version 0.0.85, under active development, it provides a unified AST representation and supports transpilation of modern JavaScript (ESM/CJS) to multiple target languages. Key differentiators: single-pass transpilation, TypeScript-first with full type definitions, and extensible transpilation rules. Ideal for multi-language codebases and tooling that requires cross-language code generation.
npm install ast-transpilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Transpiles a TypeScript function to Python using the transpile API with target language options.
Update code to use nested `options.python.version` for Python target.
Replace `parseSync` with `parse` using `await`.
Use dynamic `import()` or migrate project to ESM.
Import types exclusively from 'ast-transpiler' root.
Replace `language` with `targetLang` in options.
Add `"type": "module"` to your package.json or use .mjs extension for import.
Use `options: { python: { version: 3.9 } }` instead of `options: { pythonVersion: 3.9 }`.Use `const result = await parse(...)` instead of `parseSync(...)`.
Ensure your runtime supports ESM and that the package is resolved correctly.