Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

babel-preset-proposal-typescript

Package Overview
Dependencies
18
Maintainers
2
Versions
29
Issues
File Explorer

Advanced tools

babel-preset-proposal-typescript

Yet another Babel preset for TypeScript, only transforms proposals which TypeScript does not support now.

    2.2.0latest

Version published
Maintainers
2
Yearly downloads
16,904
decreased by-26.6%

Weekly downloads

Changelog

Source

2.2.0

Minor Changes

Readme

Source

babel-preset-proposal-typescript

GitHub Actions Codecov Codacy Grade npm GitHub Release

David Peer David David Dev

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier codechecks.io

Yet another Babel preset for TypeScript, only transforms proposals which TypeScript does not support now.

So that you can use babel to transform proposals which are current in stage 0-2 and TypeScript team will not implement them temporarily.

TOC

Enabled proposal plugins

  1. async-do-expressions
  2. class-properties
  3. class-static-block
  4. do-expressions
  5. function-bind
  6. function-sent
  7. json-strings
  8. partial-application
  9. pipeline-operator
  10. private-property-in-object
  11. record-and-tuple
  12. throw-expressions
  13. v8intrinsic - Further Detail

Install

# yarn yarn add -D babel-preset-proposal-typescript # npm npm i -D babel-preset-proposal-typescript

Options

optiondescriptiondefaults
classLoosewhether to use loose mode for class-static-block, class-properties and private-methodsundefined
decoratorsBeforeExportSee Babel Documentundefined
decoratorsLegacywhether to use legacy decorators semantictrue
isTSXwhether to enable jsx plugin with typescriptfalse, but true for /\.[jt]sx$/
pipelineOperatorimplementation of pipeline operator, minimal, smart or fsharpminimal
recordTuplePolyfillwhether to enable import record-tuple plugin and polyfill, or specific the polyfill module nametrue for Node>=14.6, it represents @bloomberg/record-tuple-polyfill
recordTupleSyntaxTyperecord-tuple syntax, hash or barhash

Usage

Note that unlike plugins, the presets are applied in an order of last to first (https://babeljs.io/docs/en/presets/#preset-ordering), so please make sure proposal-typescript is used at the last.

.babelrc

{ "presets": ["proposal-typescript"] }

Via CLI

babel input.ts --presets proposal-typescript >output.ts

Via Node API

require('@babel/core').transform('code', { presets: ['proposal-typescript'], })

Via webpack

Pipe codes through babel-loader.

loader = { test: /\.[jt]sx?$/, loader: 'babel-loader', options: { presets: ['@babel/typescript', 'proposal-typescript'], }, } // if you prefer `ts-loader` or `awesome-typescript-loader` loader = { test: /\.tsx?$/, use: [ { loader: 'ts-loader', }, { loader: 'babel-loader', options: { presets: ['proposal-typescript'], }, }, ], }

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me

Keywords

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc