{"id":27470,"library":"ts-babel","title":"ts-babel","description":"ts-babel (v6.1.7) transforms the output of the TypeScript compiler using Babel for fine-grained control over target environments. It acts as a bridge between TypeScript's compilation and Babel's polyfill and syntax transformation capabilities, allowing projects to use TypeScript for type checking and modern syntax while leveraging Babel for cross-browser compatibility. Key differentiator: avoids duplicate parsing by feeding TypeScript's emit directly into Babel, preserving source maps. Maintenance status unknown (last release likely older). Requires TypeScript ^3.5.2 as a peer dependency and Node >=8.10.0.","status":"maintenance","version":"6.1.7","language":"javascript","source_language":"en","source_url":"https://github.com/develar/ts-babel","tags":["javascript","babel","typescript"],"install":[{"cmd":"npm install ts-babel","lang":"bash","label":"npm"},{"cmd":"yarn add ts-babel","lang":"bash","label":"yarn"},{"cmd":"pnpm add ts-babel","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to compile TypeScript before Babel transformation","package":"typescript","optional":false},{"reason":"runtime dependency for Babel transformation of TypeScript output","package":"@babel/core","optional":false}],"imports":[{"note":"Default export is a function. In CommonJS, use require('ts-babel').default or set esModuleInterop.","wrong":"const tsBabel = require('ts-babel').default","symbol":"tsBabel","correct":"import tsBabel from 'ts-babel'"},{"note":"Named export is available but less commonly used; default export is recommended for single-file compilation.","wrong":"const { transform } = require('ts-babel')","symbol":"transform","correct":"import { transform } from 'ts-babel'"},{"note":"TypeScript type export, use import type for type-only imports to avoid runtime errors.","wrong":"import { TransformOptions } from 'ts-babel'","symbol":"TransformOptions","correct":"import type { TransformOptions } from 'ts-babel'"}],"quickstart":{"code":"import tsBabel from 'ts-babel';\nimport * as fs from 'fs';\n\nconst code = fs.readFileSync('example.ts', 'utf8');\ntsBabel({\n  code,\n  filename: 'example.ts',\n  typescript: true,\n  babel: {\n    presets: [\n      ['@babel/preset-env', { targets: '> 0.25%, not dead' }]\n    ]\n  }\n}).then(result => {\n  console.log(result.code);\n}).catch(err => {\n  console.error(err);\n});","lang":"typescript","description":"This shows how to compile a TypeScript file with ts-babel: takes TS code, compiles with TypeScript, then transforms with Babel preset-env for browser compatibility."},"warnings":[{"fix":"Use a version of ts-babel that supports TypeScript >=4.0 or switch to a different tool (e.g., @babel/preset-typescript).","message":"Peer dependency TypeScript ^3.5.2 may cause issues with newer TypeScript versions (4.x+).","severity":"breaking","affected_versions":">=6.1.7"},{"fix":"Migrate to @babel/preset-typescript and drop ts-babel dependency.","message":"ts-babel is not actively maintained; consider using @babel/preset-typescript with Babel directly.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use require('ts-babel').default or enable esModuleInterop in tsconfig.","message":"When using CommonJS, the default export is not available via require directly; must use .default.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Always use .then() or await when calling tsBabel() or transform().","message":"The transform function returns a promise; forgetting to await or handle errors may lead to silent failures.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install typescript@^3.5.2","cause":"Missing peer dependency TypeScript, or not installed in the project.","error":"Error: Cannot find module 'typescript'"},{"fix":"Use require('ts-babel').default or import tsBabel from 'ts-babel'.","cause":"Using require('ts-babel') without .default due to CommonJS module system.","error":"TypeError: tsBabel is not a function"},{"fix":"npm install @babel/core","cause":"Missing @babel/core which is a runtime dependency of ts-babel.","error":"Error: Cannot find module '@babel/core'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}