pass through from typescript to

pass through from typescript to

I often use typescript just for types and not for bundling or transpilation to different ES targets.

Typescript can play a few different roles that when used with a complex stack, can cause tooling confusion. To avoid confusion, I generally have typescript do as little as possible.

To have typescript passthrough everything to babel, which is configured to transpile down to my target, I set tsconfig.json to:

  • module: esnext => target an ES version that understands import/export natively.
  • moduleResolution: node => resolve modules using node semantics. This is the default, but when “module” is used, it seems to get reset to a bad value.
  • target: esnext => target the latest es environment for destructuring, default args, etc.
  • jsx: preserve: => Keep brackets (see below).
  • importHelpers; true => If typescript does happen to transpile, import tslib instead of writing some boilerplate into each output module. This saves space
  • noEmitHelpers: true => Do not emit the helper boilerplate in each module.
  • experimentalDecorators: true => Allow @decoator type syntax.
  • emitDecorationMetadata: false => Skip extra decoration metadata.

The jsx: preserve setting means that tsx => jsx and that the jsx brackets will be preserved in the output instead of being converted to React.createElement(...).


Popular posts from this blog

zio layers and framework integration

typescript and react types

dotty+scala.js+async: interesting options