Socket
Socket
Sign inDemoInstall

@babel/preset-typescript

Package Overview
Dependencies
44
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/preset-typescript

Babel preset for TypeScript.


Version published
Maintainers
4
Install size
20.0 kB
Created

Package description

What is @babel/preset-typescript?

The @babel/preset-typescript package is a Babel preset for TypeScript, which allows Babel to parse and transform TypeScript code into JavaScript. This enables developers to use TypeScript's static typing features while leveraging Babel's ability to compile modern JavaScript to be compatible with older browsers or environments.

What are @babel/preset-typescript's main functionalities?

TypeScript Compilation

Compiles TypeScript code to JavaScript by stripping out type annotations and handling TypeScript-specific syntax.

const x: number = 10;

Support for TypeScript Features

Supports various TypeScript features like enums, interfaces, and namespaces, converting them to equivalent JavaScript code.

enum Color { Red, Green, Blue }; let c: Color = Color.Green;

Integration with Babel Toolchain

Easily integrates with the Babel toolchain, allowing TypeScript files to be included in Babel's build process alongside other JavaScript files.

module.exports = { presets: ['@babel/preset-typescript'] };

Other packages similar to @babel/preset-typescript

Readme

Source

@babel/preset-typescript

Babel preset for TypeScript.

This preset includes the following plugins:

  • transform-typescript

You will need to specify --extensions ".ts" for babel-cli, babel-node 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/typescript"]
}

Via CLI

babel --presets @babel/typescript script.ts

Via Node API

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

Keywords

FAQs

Last updated on 30 Oct 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc