Détail du package

babel-preset-proposal-typescript

un-ts5.7kMIT4.0.0

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

babel-preset, babel-preset-ts, babel-preset-typescript, @babel/preset-ts

readme

babel-preset-proposal-typescript

GitHub Actions Codecov 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. destructuring-private
  3. do-expressions
  4. duplicate-named-capturing-groups-regex
  5. function-bind
  6. function-sent
  7. import-defer
  8. import-wasm-source
  9. optional-chaining-assign
  10. partial-application
  11. pipeline-operator
  12. record-and-tuple
  13. regexp-modifiers
  14. throw-expressions
  15. 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
importDefer Whether to enabled import-defer plugin, if true transform-modules-commonjs will be enabled automatically false
isTSX Whether to enable jsx plugin with typescript false, but true for /\.[jt]sx$/
optionalChainingAssignVersion Version for optional-chaining-assign plugin, only '2023-07' allowed for now '2023-07'
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'],
      },
    },
  ],
}

References

Sponsors

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Backers

Backers

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Changelog

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

License

MIT © JounQin@1stG.me

changelog

Changelog

4.0.0

Major Changes

3.0.0

Major Changes

  • d0e4cf2 Thanks @JounQin! - feat!: upgrade to typescript@v4.7, remove unnecessary plugins

Minor Changes

  • d0e4cf2 Thanks @JounQin! - feat: babel-preset-proposal-typescript is now a dual (commonjs + ESM) package

2.2.0

Minor Changes

  • c29d8f7 Thanks @JounQin! - feat: disable private-methods for typescript 4.3+

2.1.0

Minor Changes

  • #115 Thanks @JounQin!

    • 50d6199 feat: upgrade babel core and plugins
    • db510c9 feat: enable async-do-expressions and record-and-tuple proposals
    • 1dd2ff6 feat!: change classLoose default valule to false and presets order

2.0.3

Patch Changes

2.0.0 (2021-01-26)

⚠ BREAKING CHANGES

  • bump babel and typescript, add two proposals

Features

  • bump babel and typescript, add two proposals (3f18e81)

1.5.0 (2019-11-10)

Features

  • drop nullish-coalescing-operator and optional-chaining in favor of typescript 3.7.0 (0fe0093)

1.4.6 (2019-11-10)

Features

  • better TypeScript support (66f65c5)

Bug Fixes

  • lock rollup-plugin-url@^2.2.4 for node 8 (d0b7bae)

1.4.5 (2019-10-09)

1.4.4 (2019-10-09)

Bug Fixes

  • check typeof decoratorsBeforeExport (336dc46)

1.4.3 (2019-10-09)

Bug Fixes

  • add decoratorsBeforeExport options for decorators (1b84269)

1.4.2 (2019-10-09)

Bug Fixes

  • compatible with decorators + class properties (11f7ec4)

1.4.1 (2019-09-09)

Bug Fixes

  • test: code coverage issue, remove unnecessary tempy dep (71b6765)

1.4.0 (2019-09-07)

Bug Fixes

  • deps: bump babel which supports private static accessors (eb1880d)

Features

  • enable v8intrinsic plugin (7f83401)

1.3.0 (2019-09-03)

Features

  • add cjs/esm/es2015 bundle via @1stg/rollup-config (93e4786)

1.2.6 (2019-08-20)

Bug Fixes

  • incorrect type of overrides (d86062a)

1.2.5 (2019-08-20)

Features

1.2.4 (2019-08-18)

1.2.3 (2019-08-18)

Bug Fixes

  • determine jsx/tsx automatically (56a08a2)

1.2.2 (2019-08-18)

Features

  • add options support, import documentation (e2c2064)

1.2.1 (2019-08-18)

Bug Fixes

  • babel plugins should be dependencies (1ca379c)

1.2.0 (2019-08-17)

Features

  • add latested proposal plugins (a7f09da)

1.1.0 (2019-08-17)