This package, `@babel/plugin-transform-typescript`, is a core Babel plugin designed to strip TypeScript type annotations from code, transforming it into standard ECMAScript. It operates solely on the syntax level and does not perform any type-checking; users must integrate the TypeScript compiler (tsc) separately for type validation. The current stable major version is 7 (e.g., v7.29.2 as of March 2026), with active development ongoing for Babel 8, which is currently in release candidate stages (e.g., v8.0.0-rc.3). Babel maintains a frequent release cadence for patch versions and rolls out minor/major updates periodically. A key differentiator is its focus on pure syntax transformation, which makes it faster than a full TypeScript compilation but also means it explicitly does not support TypeScript-specific features like `namespace` declarations, `const enum`s, or the legacy `export =` and `import =` syntax, as these features require type information for meaningful transformation.
npm install babel-plugin-transform-typescriptVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install and configure `@babel/plugin-transform-typescript` to transpile a TypeScript file containing interfaces, type-only imports, and functions into standard JavaScript using the Babel CLI.
Migrate `module <identifier> { ... }` declarations to modern ES Modules using `import`/`export` syntax, or consider using TypeScript's `namespace` feature with appropriate Babel configuration if absolutely necessary (though `namespace` is generally discouraged in favor of ES Modules).Integrate `tsc` into your build process to perform type checking. A common pattern is to use Babel for transpilation and `tsc` solely for type verification (e.g., `tsc --noEmit`).
Avoid using `namespace`, `const enum`, `export =`, and `import =`. Prefer modern ES Module `import`/`export` statements. For constant-like enums, consider regular `enum`s or plain objects/literals.
Review the full Babel 8 upgrade guide carefully. Test your entire build pipeline thoroughly when moving from Babel 7 to Babel 8. Pay attention to parser options, default behaviors, and deprecated features.
Ensure `@babel/plugin-transform-typescript` is installed (`npm install --save-dev @babel/plugin-transform-typescript`) and correctly specified in your `babel.config.js` or `.babelrc` (e.g., `plugins: ['@babel/plugin-transform-typescript']`).
Run `tsc --noEmit` as part of your build process or ensure your IDE/editor is configured to show TypeScript errors. Correct the type mismatch in your source code.
Refactor your code to use ES Module `import`/`export` instead of `namespace`, and use standard `enum`s or plain JavaScript objects/literals instead of `const enum`s.