Skip to content

feat: typescript support#19

Draft
jacob-ebey wants to merge 5 commits into
macaly:mainfrom
jacob-ebey:typescript
Draft

feat: typescript support#19
jacob-ebey wants to merge 5 commits into
macaly:mainfrom
jacob-ebey:typescript

Conversation

@jacob-ebey
Copy link
Copy Markdown

No description provided.

   Run TypeScript files directly through the runtime, mirroring Node.js's
   native type-stripping (stable since Node 23.6). `node app.ts`,
   `require('./mod.ts')`, and `index.ts` directory resolution now work out
   of the box.

   Implemented with `acorn-typescript`, a pure-JS acorn plugin — no
   `typescript` compiler dependency and no wasm. This keeps stripping
   synchronous (required for `require()`) and adds minimal bundle weight
   (index.mjs stays ~1.2MB rather than ballooning to ~10MB as it would by
   pulling in the full typescript package).

   Type-only syntax is replaced with whitespace, preserving source
   positions: annotations, interfaces, type aliases, generics,
   `import type`/`export type`, `as`/`satisfies`, non-null `!`, definite
   assignment, `declare`, class member modifiers, and `implements`.

   Details:
   - New `src/frameworks/strip-types.ts`: parses with acorn-typescript and
     blanks TS-only AST node ranges, then the existing ESM→CJS pipeline runs.
   - runtime.ts: strip types before the ESM→CJS transform in loadModule and
     execute; .cts treated as CommonJS, .mts/.ts as ESM-capable; added
     .ts/.mts/.cts (and index.* variants) to module resolution.
   - child_process.ts: `node` command resolves .ts files, including the
     extensionless `node app` -> app.ts case.

   Matches Node's strip-only mode: constructs needing code generation
   (enums, namespaces, parameter-property assignment) are not emitted.
   Only .ts/.mts/.cts are handled; .tsx/JSX continues to go through the
   Vite/Next dev servers via esbuild.

   Adds tests/typescript-files.test.ts and `node app.ts` coverage in
   tests/child_process.test.ts. Full suite (2261) green, tsc clean.
…local binding preservation for named exports
@jacob-ebey jacob-ebey marked this pull request as draft June 2, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant