babel/packages/babel-preset-typescript

@babel/preset-typescript

Babel preset for TypeScript.

This preset includes the following plugins:

You will need to specify --extensions ".ts" for @babel/cli & @babel/node cli's to handle .ts files.

Example

In

const x: number = 0;

Out

const x = 0;

Installation

npm install --save-dev @babel/preset-typescript

Usage

.babelrc

{
  "presets": ["@babel/preset-typescript"]
}

Via CLI

babel --presets @babel/preset-typescript script.ts

Via Node API

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

Options

jsxPragma

string

Replace the function used when compiling JSX expressions.

This is so that we know that the import is not a type import, and should not be removed