JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1311
  • Score
    100M100P100Q113392F
  • License MIT

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

Package Exports

  • babel-preset-proposal-typescript

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-preset-proposal-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

babel-preset-proposal-typescript

GitHub Actions Codecov Codacy Grade npm GitHub Release

David Peer David David Dev

Conventional Commits 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. class-properties
  2. do-expressions
  3. function-bind
  4. function-sent
  5. json-strings
  6. logical-assignment-operators
  7. partial-application
  8. pipeline-operator
  9. private-methods
  10. throw-expressions
  11. v8intrinsic - Further Detail

Install

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

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

Options

option description defaults
classLoose whether to use loose mode for class properties and private methods true
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"

Usage

.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: ['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'],
      },
    },
  ],
}