The `babel-preset-proposal-typescript` (currently v4.0.0) is a Babel preset designed to enable experimental ECMAScript proposals in TypeScript projects that TypeScript itself does not yet natively support. This includes features like async do expressions, record and tuple, pipeline operator, and more, allowing developers to utilize cutting-edge syntax while still leveraging TypeScript's type-checking capabilities for standard features. The preset maintains an active development pace, with major versions typically aligned with updates to its core peer dependencies: `@babel/core` (currently `^7.23.0`) and `typescript` (currently `^5.3.0`). Its primary differentiator is its focused scope: it specifically fills the gap for proposals that the TypeScript team explicitly postpones or chooses not to implement, avoiding redundant transformations with `@babel/preset-typescript` or other standard presets.
npm install babel-preset-proposal-typescriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to configure Babel with `babel-preset-proposal-typescript` to compile TypeScript code utilizing experimental ECMAScript proposals like `do expressions`, `record and tuple`, and `pipeline operator`.
Ensure `@babel/core` is `^7.23.0` or higher and `typescript` is `^5.3.0` or higher in your `package.json` peer dependencies. Then run `npm install` or `yarn install`.
Upgrade your `typescript` dependency to `^4.7.0` or later. Review your Babel configuration as some previously managed plugins might now be handled natively by TypeScript or are no longer needed.
Consult the changelog for `v2.0.0` to identify specific plugin changes or removals. Upgrade your Babel and TypeScript peer dependencies to meet the new requirements.
For `nullish-coalescing-operator` and `optional-chaining`, ensure your project uses TypeScript 3.7.0 or newer and that `@babel/preset-typescript` (or similar) is configured to handle modern TypeScript syntax. This preset is strictly for proposals TypeScript *does not* yet support.
Regularly review the changelog for this preset and the TypeScript release notes. Ensure your Babel configuration remains lean, relying on `@babel/preset-typescript` for standard TypeScript features and this preset only for the explicitly unsupported proposals.
Ensure `babel-preset-proposal-typescript` is listed in your `devDependencies` and installed: `npm install --save-dev babel-preset-proposal-typescript` or `yarn add -D babel-preset-proposal-typescript`.
Upgrade `@babel/core` to the required version: `npm install --save-dev @babel/core@^7.23.0` or `yarn add -D @babel/core@^7.23.0`.
Upgrade `typescript` to the required version: `npm install --save-dev typescript@^5.3.0` or `yarn add -D typescript@^5.3.0`.
Ensure the preset is listed as a simple string `"babel-preset-proposal-typescript"` or an array `["babel-preset-proposal-typescript", { /* options */ }]` if you need to pass options.