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.
- async-do-expressions
- destructuring-private
- do-expressions
- duplicate-named-capturing-groups-regex
- function-bind
- function-sent
- import-defer
- import-wasm-source
- optional-chaining-assign
- partial-application
- pipeline-operator
- record-and-tuple
- regexp-modifiers
- throw-expressions
- v8intrinsic - Further Detail
# yarn
yarn add -D babel-preset-proposal-typescript
# npm
npm i -D babel-preset-proposal-typescript| option | description | defaults | 
|---|---|---|
| decoratorsBeforeExport | See Babel Document | undefined | 
| decoratorsLegacy | Whether to use legacy decorators semantic | true | 
| importDefer | Whether to enabled import-deferplugin, if truetransform-modules-commonjswill be enabled automatically | false | 
| isTSX | Whether to enable jsxplugin withtypescript | false, buttruefor/\.[jt]sx$/ | 
| optionalChainingAssignVersion | Version for optional-chaining-assignplugin, only'2023-07'allowed for now | '2023-07' | 
| pipelineOperator | Implementation of pipeline operator, minimal,smartorfsharp | minimal | 
| recordTuplePolyfill | Whether to enable import record-tupleplugin and polyfill, or specific the polyfill module name | truefor Node>=14.6, it represents@bloomberg/record-tuple-polyfill | 
| recordTupleSyntaxType | record-tuplesyntax,hashorbar | hash | 
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"]
}babel input.ts --presets proposal-typescript > output.tsrequire('@babel/core').transform('code', {
  presets: ['proposal-typescript'],
})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'],
      },
    },
  ],
}| 1stG | RxTS | UnTS | 
|---|---|---|
| 1stG | RxTS | UnTS | 
|---|---|---|
Detailed changes for each release are documented in CHANGELOG.md.