examples/typescript-non-erasable/template.md
Webpack 5 includes a built-in TypeScript transform via
experiments.typescript: true (see the examples/typescript example).
That transform uses Node.js's module.stripTypeScriptTypes and therefore
only handles the erasable TypeScript subset — types, import type,
as-casts, generics, etc. It rejects syntax that emits runtime code:
enum, namespace, parameter-property constructors, export =, decorator
metadata, JSX/.tsx.
If your project uses any of that non-erasable syntax, keep using a real
TypeScript transpiler. This example shows the classic setup with
ts-loader plus fork-ts-checker-webpack-plugin for type checking.
_{{example.js}}_
_{{index.ts}}_
_{{webpack.config.js}}_
_{{dist/output.js}}_
_{{stdout}}_
_{{production:stdout}}_