Repository navigation
feat(ts): type-check the whole output before a translation succeeds - #376
Merged
Merged
Conversation
Quest-Claim: 181465303445f10c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 1, 2026 06:55
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
kixelated
enabled auto-merge (squash)
November 1, 2026 06:56
kixelated
added a commit
that referenced
this pull request
Nov 1, 2026
…yte-fields Drops the reject fixture's `mistyped` case, which #376 wrote through the typing gap this branch closes: no other typing gap that translation leaves to `tsc` is known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes quest/m3/ts-check-output.md.
Problem
Translation succeeded on output
tscrejects. Only the check module of bindings was type-checked, so a typing gap surfaced in the consumer's owntsc, far from the Rust that caused it. Reproduced onmainwith a generic type'sVec<T>atu8(the gap ts-generic-byte-fields tracks):rust2-tsexits 0, thentscreportslib.Window.ts(18,20): error TS2339: Property 'data' does not exist on type 'u8[]'andlib.ts(8,53): error TS2740: Type 'ByteVec' is missing ....Approach
tscrun (moved fromlower/bind.rstots/src/check.rs, since it now checks the whole output) lists every translated module in its project beside the check module. Onetscprocess, same settings as before: the runtime's strictness without the unused-name lints.print::modulereturns its source-map tokens and each item's first line, andProgram::writereturns every module as printed. A diagnostic in a translated module reports at the Rust span of the last mapping at or before it in the same item, else at the item's symbol span, else without a span.Sourcekeeps rustc's file start so aLocmaps back to aSpan.lib.ts:8:47 doesn't type-check, which is a bug in rust2-ts: error TS2740: .... Each (span, message) is reported once, so a generic function's instances fail once.bind/wrong.toml: 7 extra errors inharness.ts). Errors in translated modules are reported only when no binding or other file failed. Translation fails in both cases.function check$N.reject/mistyped.tomltranslates that gap and expects both errors at their Rust spans, with the output removed.Cost on moq-net's pinned translation (19 modules, 90 files with the runtime and libs): the
tscrun takes 0.20 s wall, 0.8 s CPU, 100 MB (8 runs,tsc7.0.2). The whole translation takes about 15 s. End-to-end timings with and without the check differ by less than host noise.Impact
tscrejects, where it succeeded before.ts/MIGRATE.mdnotes it.tsc7.0 or later onPATH, not only one with bindings. The flake's package and dev shell already provide it.Alternatives
tscrun with the runtime's full settings (noUnusedLocals): it would also catch unused names, but those are lint, binding files may leave them, and it doubles the process cost.just ts testandjust ts moqstill check the fixtures and moq with them.include: ["../**/*.ts"]instead of listing files: it would check hand-written files a caller keeps in the output directory, whichcleandeliberately keeps.Choices made without asking: errors in translated code are held back while a binding fails; a diagnostic outside any mapping reports without a span rather than at a guessed one.
Follow-ups
returnmaps to its closing}and a call to its method name, so a check error points there. A finer map would sharpen these spans. Not recorded as a quest yet.mistypedcase to another typing gap.Checks
just cipassed locally insidenix developon 4dd8cf6.Review
gpt-6.1-sol, medium effort, viaquest review --base origin/main.origin/main(fix(ts): a &mut into a Box is the place holding the box #369), which needs no new review;just cipassed on it.(written by Claude Opus 5.5)
🤖 Generated with Claude Code