babel/packages/babel-plugin-transform-typescript
Josh Justice b8d1d221f8 Rename actual/expected test files to input/output (#7578)
These files appear to have been missed in the update of test file naming from actual/expected.js to input/output.js. As a result, they were silently not being run. I've confirmed that they were not running, updated the names, then confirmed that they are running now.
2018-03-15 19:02:41 +01:00
..
2018-03-14 12:25:26 -04:00

@babel/plugin-transform-typescript

Transform TypeScript into ES.next.

Does not type-check its input. For that, you will need to install and set up TypeScript.

Caveats

  • Does not support namespaces. Workaround: Move to using file exports, or migrate to using the module { } syntax instead.
  • Does not support const enums because those require type information to compile. Workaround: Remove the const, which makes it available at runtime.
  • Does not support export = and import =, because those cannot be compile to ES.next. Workaround: Convert to using export default and export const, and import x, {y} from "z".

Example

In

const x: number = 0;

Out

const x = 0;

Installation

npm install --save-dev @babel/plugin-transform-typescript

Usage

.babelrc

{
  "plugins": ["@babel/plugin-transform-typescript"]
}

Via CLI

babel --plugins @babel/plugin-transform-typescript script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/plugin-transform-typescript"]
});