@babel/preset-typescript
In
Out
const x = 0;
{
"presets": ["@babel/preset-typescript"]
}
Via CLI
Via Node API
presets: ["@babel/preset-typescript"],
boolean
, defaults to false
Forcibly enables jsx
parsing. Otherwise angle brackets will be treated as typescript’s legacy type assertion var foo = <string>bar;
. Also, isTSX: true
requires allExtensions: true
.
jsxPragma
Replace the function used when compiling JSX expressions. This is so that we know that the import is not a type import, and should not be removed.
allExtensions
, defaults to false
Indicates that every file should be parsed as TS or TSX (depending on the isTSX
option).
boolean
, uses the default set by @babel/plugin-transform-typescript
.
Enables compilation of TypeScript namespaces.
allowDeclareFields
When enabled, type-only class fields are only removed if they are prefixed with the declare
modifier:
onlyRemoveTypeImports
boolean
, defaults to false
When set to true
, the transform will only remove (introduced in TypeScript 3.8). This should only be used if you are using TypeScript >= 3.8.