{ } qjs-modules

loaders/typescript

Source: lib/loaders/typescript.js (JS wrapper over registerHooks()) — default export: installTypeScript(); qjsm only

Loads .ts and .mts modules (format module-typescript) by stripping their types with node's module.stripTypeScriptTypes (swc in strip-only mode, node 22.13+ in PATH), run through std.popen. Types are blanked out with spaces, not checked, so line and column numbers stay exact.

import installTypeScript from 'loaders/typescript';

installTypeScript();
const { A } = await import('./a.ts');
await import('./a');          // extensionless: tries .ts, .mts, /index.ts
BehaviorDetail
Commandnode -e "<stripTypeScriptTypes(readFileSync(file))>" <file>
Supportederasable syntax only: annotations, interfaces, type aliases, generics, as/satisfies, declare, import type
Rejectedenum, namespace with values, parameter properties, import x = require(): the load throws
ErrorsError: cannot strip types of '<file>': <node's error line>, or cannot run node for '<file>'
Not covered.tsx (JSX), .cts / commonjs-typescript.

Exports

ExportKindDescription
installTypeScript()functionRegisters the resolve/load hooks; returns the registerHooks() result (deregister()).(default export)