@runtime-type-inspector/transpiler 4.0.6 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,23 @@
1
1
  Transpiler package for `runtime-type-inspector`.
2
2
 
3
3
  This is implementing the source code transformation, generating code eventually executed in combination with `@runtime-type-inspector/runtime`.
4
+
5
+ ## CLI
6
+
7
+ After installing, two commands are available via `npx`:
8
+
9
+ - `transpiler <file.js>` - insert runtime type-checking assertions for the JSDoc types in a file.
10
+ - `ts2js <file.ts>` - convert a TypeScript file into plain ESM JavaScript with the types preserved as JSDoc comments (no transpilation step needed afterwards).
11
+
12
+ ## `ts2js`
13
+
14
+ Converts TypeScript into `.js` + JSDoc. Type-only imports become `@import` comments
15
+ (`import type {Foo} from './foo'` -> `/** @import { Foo } from './foo.js' */`), so no
16
+ runtime import is emitted. The common TypeScript surface is covered (functions,
17
+ interfaces/aliases, enums, generics, classes including `implements`, unions, tuples,
18
+ rest params, TSX, `import = require`); `namespace` blocks are converted to the classic
19
+ IIFE pattern (`var N; (function (N) { ... })(N || (N = {}));`). See `test/ts2js.mjs`
20
+ for the exact snapshot coverage.
21
+
22
+ The conversion preserves types but does not verify them - runtime validation is still
23
+ provided by `@runtime-type-inspector/runtime` via `addTypeChecks`.