Coder Social home page Coder Social logo

lgtm-migrator / babel-preset-proposal-typescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from un-ts/babel-preset-proposal-typescript

0.0 0.0 0.0 923 KB

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

License: MIT License

JavaScript 9.59% TypeScript 90.41%

babel-preset-proposal-typescript's Introduction

babel-preset-proposal-typescript

GitHub Actions Codecov Language grade: JavaScript npm GitHub Release

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier changesets

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. do-expressions
  3. function-bind
  4. function-sent
  5. json-strings
  6. partial-application
  7. pipeline-operator
  8. record-and-tuple
  9. throw-expressions
  10. v8intrinsic - Further Detail

Install

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

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

Options

option description defaults
decoratorsBeforeExport See Babel Document undefined
decoratorsLegacy whether to use legacy decorators semantic true
isTSX whether to enable jsx plugin with typescript false, but true for /\.[jt]sx$/
pipelineOperator implementation of pipeline operator, minimal, smart or fsharp minimal
recordTuplePolyfill whether to enable import record-tuple plugin and polyfill, or specific the polyfill module name true for Node>=14.6, it represents @bloomberg/record-tuple-polyfill
recordTupleSyntaxType record-tuple syntax, hash or bar hash

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.

Via .babelrc (Recommended)

.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

babel-preset-proposal-typescript's People

Contributors

jounqin avatar github-actions[bot] avatar renovate-bot avatar greenkeeper[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.