Skip to content

tsc filter: "TypeScript: No errors found" is printed on a non-zero exit, so a tsc that never ran reads as a clean typecheck #3220

Closed

Description

@adrianmizzi

Summary

rtk tsc derives its verdict from the number of diagnostics it manages to parse, without consulting the exit code. So any failure that produces no parseable file(line,col): error TSxxxx lines is reported as success:

TypeScript: No errors found

…while the process exits non-zero. The exit code itself is propagated correctly — it is the human-readable summary that asserts the opposite of the truth.

The simplest trigger is TypeScript not being installed at all. This is easy to hit in a fresh git worktree, a clean CI checkout, or any tree where pnpm install hasn't run yet — precisely the situations where you most want a typecheck to be believed.

Affected version

rtk 0.43.0, Homebrew, macOS arm64 (Darwin 25.5.0).

Still present in v0.44.0: no file matching tsc/typescript appears among the 117 files changed in v0.43.0...v0.44.0, and there is no tsc entry in the changelog.

Reproduction

D=$(mktemp -d); cd "$D"
echo '{"name":"x","private":true}' > package.json
echo '{}' > tsconfig.json

# No TypeScript in this project.
pnpm exec tsc --noEmit; echo "raw exit=$?"
rtk tsc --noEmit;       echo "rtk exit=$?"

Result:

--- raw ---
 This is not the tsc command you are looking for
 To get access to the TypeScript compiler, tsc, from the command line either:
 - Use npm install typescript to first add TypeScript to your project before using npx
raw exit=1

--- rtk ---
TypeScript: No errors found
[full output: ~/Library/Application Support/rtk/tee/<ts>_tsc.log]
rtk exit=1

Expected vs actual

Expected Non-zero exit with zero parsed diagnostics ⇒ report a failure and surface the raw output (it is already captured in the tee log).
Actual TypeScript: No errors found, i.e. an affirmative claim that the code type-checks, on a tree that was never compiled.

Why this one bites harder than a normal lossy filter

The consumer is an LLM agent, and the summary line is the part it reads and acts on. A truncated rtk grep is self-evidently incomplete and gets re-run; TypeScript: No errors found is a confident verdict with nothing to suggest otherwise.

Concretely: in a fresh worktree I ran a typecheck, got TypeScript: No errors found, and treated a ~1,000-line change as verified. It was caught only because a later command failed for an unrelated reason and I re-ran the same typecheck through rtk proxy, which showed the real error. A filter that can silently convert "didn't run" into "passed" is a correctness issue rather than a display one.

Relationship to #1772

#1772 (open since 2026-05-07, filed against 0.39.0) reports the identical assertion — TypeScript: No errors found alongside a non-zero exit — triggered by --pretty. I believe both are the same root cause: the verdict is computed from parsed diagnostics rather than from the exit status, and --pretty merely happens to be one way of defeating the parser.

I've filed separately because #1772's title scopes it to --pretty, and a fix confined to the --pretty path would leave this trigger (and any future one) intact. Very happy for this to be closed as a duplicate if you'd rather track it there — the substantive request is that the fix be the general exit-code guard, not per-trigger parser patches.

Possibly related: #2809 (pnpm typecheck mis-rewritten) and #1811 (--noEmit dropped, emitting real .js/.map artifacts).

Suggested fix, and the precedent already in 0.44.0

v0.44.0 fixed exactly this class of bug in the cargo filter:

  • fix(cargo): give the json batch filter the exit code (a3e65e9)
  • fix(cargo): restore failure check before trusting reused build filter (e4bfe35)
  • fix(cargo): keep "No issues found" wording for clean clippy json runs (1f74614)

The same invariant applied to the tsc path would cover every trigger at once:

Never emit a success verdict when the child exited non-zero. If the exit is non-zero and zero diagnostics were parsed, treat it as unparsed output: print a failure header and pass through (or tee-hint) the raw text.

An audit of the other verdict-style filters for the same pattern seems worthwhile — the guard belongs wherever a filter summarises a pass/fail rather than merely compacting output.

Workaround

Excluding the command from the hook restores ground truth, at the cost of that filter's savings:

# ~/Library/Application Support/rtk/config.toml
[hooks]
exclude_commands = ["pnpm exec tsc", "pnpm typecheck", "npx tsc", "npm run tsc"]

Worth noting exclude_commands matches a prefix of the raw command ("pnpm exec tsc"), not the rtk subcommand ("tsc") — which wasn't obvious from the config file, and might deserve a comment in the generated default.

Thanks for rtk — rtk grep alone accounts for ~89% of the 68.7M tokens it has saved me, so this report is very much in the spirit of keeping the rest trustworthy.

Activity

  1. added
    bug
    good first issue
    on Jul 26, 2026
  2. pszymkowiak commented on Jul 26, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 93%

    Summary

    tsc filter emits 'TypeScript: No errors found' even on non-zero exit when no diagnostics are parseable (e.g. tsc missing), falsely signaling a clean typecheck; needs an exit-code guard like the 0.44.0 cargo filter fix.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/filters/tsc.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. nightcityblade commented on Jul 26, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  4. added 2 commits that reference this issue on Jul 29, 2026
    7e751c6
    2dd5708
  5. triggerhive-gijs commented on Aug 10, 2026

    @triggerhive-gijs

    Two more reproductions on rtk 0.45.0, both of which produce TypeScript: No errors found when nothing was actually typechecked.

    1. tsc runs but rejects its own invocation (TS5112). A file argument alongside a tsconfig.json:

    $ ./node_modules/.bin/tsc --noEmit bad.ts
    error TS5112: tsconfig.json is present but will not be loaded if files are specified on commandline. Use '--ignoreConfig' to skip this error.
    
    $ rtk tsc --noEmit bad.ts
    TypeScript: No errors found
    

    bad.ts contains three genuine type errors. None of them were reported, because tsc never got as far as checking.

    2. tsc never starts at all. With a broken install, the binary dies before emitting anything tsc-shaped:

    $ ./node_modules/.bin/tsc --noEmit a.ts
    Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../node_modules/lib/tsc.js'
        at finalizeResolution (node:internal/modules/esm/resolve:272:11)
        [... Node stack trace ...]
    
    $ rtk tsc --noEmit a.ts
    TypeScript: No errors found
    

    So it is not specific to TS5112. Any failure whose output does not match the file(line,col): error TSxxxx shape collapses to the success message.

    Worth adding to the priority case: the exit code is propagated correctly (1 in both examples above). The bug is purely in the summary line. That distinction matters more than it might seem, because the main consumer of this output is now an LLM agent reading the text rather than a shell checking $?. An agent that sees TypeScript: No errors found will report the typecheck as green and move on, and the correct exit code never enters its reasoning.

    A summary line that reflects the exit code — for example TypeScript: tsc exited 1 with no parsable diagnostics and the raw output retained — would fail closed instead of open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibuggood first issuepriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions