Skip to content

Write the JavaScript from the type check, and run Jest without a transformer (draft) - #105

Draft
exercism-agent[bot] wants to merge 1 commit into
mainfrom
tsc-emit
Draft

exercism-agent[bot] wants to merge 1 commit into
mainfrom
tsc-emit

Conversation

@exercism-agent

@exercism-agent exercism-agent Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Hello 🙂 I'm working with Claude to try and get our tooling faster.

This draft makes this project around 20% faster on top of #104. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explain stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...


This is the first of three draft PRs. #103 and #104 are merged, so it is now based on main. Merge it first, then #106 and #107. This PR works without the other two.

What changed

Each run already type-checks the solution with tsc --noEmit. tsc then throws its work away, and Babel strips the types again when Jest loads each file. Loading Babel and running it takes a large part of each run.

The new bin/compile.cjs runs tsc's own command-line code, so its output and exit code match tsc --noEmit exactly. After the check, it turns emit on in the same program and writes CommonJS and source maps to a temporary folder. For the test file, bin/compile.cjs just strips the types, with transpileModule. Jest then runs the written files with no transformer (transform: {}).

  • Writing the files adds 0.08s to 0.17s to the type check.
  • Stack traces and console output still point at the right .ts lines, through the source maps.
  • Type errors look exactly as they do today.
  • Enums and parameter properties work, because tsc writes their code itself.
  • It adds no new dependency, and works in a read-only container.

Every test passes or fails as before. Three messages change:

  • Errors name imports two_fer_ts_1 where Babel's output gave _twoFer.
  • Stack frames name functions with their real names, for example at twoFer where Babel's output said at a.
  • A syntax error in the test file uses TypeScript's wording, with no code frame.

Two fixture messages are updated to match.

I also tried SWC to strip the types. It was about as fast (SWC 2.80s, this PR 2.87s, both warm). But it adds 53 MB to the image, and it needs a native library that fails to load in a read-only container unless it is unpacked at build time.

This has been tested in production, and with all the PRs merged has reduced the median run from 11.8s to 3.3s.

🤖 Generated with Claude Code

Base automatically changed from warm-up-image to report-missing-tests November 24, 2026 10:05
@exercism-agent
exercism-agent Bot force-pushed the report-missing-tests branch from 1d764a5 to 3b47f73 Compare November 24, 2026 10:15
Base automatically changed from report-missing-tests to main November 24, 2026 10:19
…sformer

Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SleeplessByte

Copy link
Copy Markdown
Member

Can this now be undrafted?

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.

2 participants