You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rtk pnpm typecheck incorrectly rewrites command to pnpm tsc #2809
When running rtk pnpm typecheck in the root of a project, rtk incorrectly rewrites the command to pnpm tsc (or runs tsc directly), executing a TypeScript build rather than running the typecheck script defined in package.json.
In the reproduction project's package.json, typecheck is defined to use Turborepo:
"scripts": {
"typecheck": "turbo run typecheck"
}
Instead of running pnpm run typecheck (which would trigger turbo run typecheck), rtk rewrites and executes pnpm tsc.
Clone the reproduction repository and navigate into it:
git clone https://github.com/tanakalucky/rtk-pnpm-typecheck-rewrite-test.git
cd rtk-pnpm-typecheck-rewrite-test
Install dependencies:
pnpm install
Run the reproduction command:
rtk pnpm typecheck
Expected Behavior
rtk should execute pnpm typecheck, which in turn runs the script defined in package.json (turbo run typecheck).
Actual Behavior
rtk rewrites the command to pnpm tsc (or runs tsc directly) and starts a compiler build, ignoring the custom script definition in package.json.
Reacted by EDM115, Tomi Turtiainen and Aryan Rahman
rtk's command-rewrite logic incorrectly maps pnpm typecheck to pnpm tsc/tsc instead of passing through to the package.json script (e.g. turbo run typecheck); fix the pnpm rewrite rule to respect custom script definitions.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/rewrite/pnpm.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
actually, rtk should use its tsc filter only if the typecheck script contains it.
matching for that however can be complex :
matching simply for the command starting with tsc won't cut it since we can have env vars set
matching for tsc in the middle of the command can also be wrong, what if our typecheck command actually runs tsc --noEmit; cd src/rust && cargo check --all-targets --all-features ? command separators are also different based on platforms
matching for tsc alone might also be wrong, what if we call vue-tsc ? or run a tsc.sh file that does some stuff before calling itself pnpm exec tsc ?
Adding evidence found while reviewing #3676, which would have made this fire by default for every user rather than only for people who explicitly type rtk pnpm typecheck.
There is a write side effect that isn't in the original report: the dropped --noEmit causes tsc to emit compiled JavaScript into the project.
main.rs:2096 dispatches PnpmCommands::Typecheck to tsc_cmd::run(Some("pnpm"), &args, …), which runs tsc with only the args aftertypecheck. For a bare pnpm typecheck that list is empty, so every flag the script carried — including --noEmit — is lost.
Reproduced on current develop (79b96a4), real project, "typecheck": "tsc --noEmit", tsconfig.json with outDir: "./dist":
# pnpm 12.4.1
$ pnpm typecheck
$ tsc --noEmit
exit=0 dist/ -> does not exist
$ rtk -v pnpm typecheck
Running: pnpm tsc
TypeScript: No errors found
exit=0 dist/ -> index.js <-- written
# pnpm 9 (same result, reached via bare `tsc` since tool_exists("tsc") is false there)
$ rtk -v pnpm typecheck
Running: tsc
exit=0 dist/ -> index.js <-- written
A read-only type check acquires a write side effect. On a project whose typecheck script is not tsc at all, the same path turned exit 0 with 1392 bytes of real output into exit 1 with a fabricated TypeScript: No errors found.
Other shapes broken by the same mechanism, beyond the Turborepo case in the report:
"typecheck": "vue-tsc --noEmit" / svelte-check — the wrong binary runs; for .vue / .svelte the result is meaningless
"typecheck": "tsc -b" — project-references build, not a plain check
"typecheck": "tsc -p tsconfig.app.json" — the default tsconfig.json is checked instead, so a green result is a false pass over a different file set
monorepo root with no tsconfig.json — bare tsc errors where pnpm typecheck would have fanned out to workspaces
tsc not on PATH — tool_exec(…, MissingTool::Fetch) pulls TypeScript from the network
Two possible fixes, depending on what rtk pnpm typecheck is meant to be:
Make PnpmCommands::Typecheck actually run pnpm typecheck and filter the tsc-shaped output it produces, keeping the script as the source of truth; or
Drop the Typecheck variant entirely and let it fall through to PnpmCommands::Other → passthrough, the way test / build / format already do.
Option 2 is the smaller change and matches what the other script names already do. Option 1 keeps the filtering benefit but has to stop assuming the script is tsc.
Either way the validate_pnpm_filters FIXME in main.rs is standing evidence that this delegation was already known to be lossy.
Another repro, on a project where the typecheck script does not use tsc at all and tsc is not installed.
Environment
rtk 1.2.1
pnpm 12.23.0
Linux x86_64
package.json
"typecheck": "tsrs --noEmit --fast"
Expected (rtk proxy pnpm typecheck)
$ tsrs --noEmit --fast
src/components/example.tsx(77,30): error TS2339: Property 'foo' does not exist on type '...'.
src/components/example.tsx(77,93): error TS2339: Property 'bar' does not exist on type '...'.
[ELIFECYCLE] Command failed with exit code 2.
Actual (rtk pnpm typecheck)
TypeScript: compiler exited with code 1, but RTK parsed no diagnostics
Error: ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL
× Command "tsc" not found
Impact
The package script never runs. rtk runs pnpm exec tsc instead.
The two real type errors are hidden. The output shows only an unrelated "tsc not found" error.
The exit code changes from 2 to 1.
This happens only with the explicit rtk pnpm typecheck form. The hook does not rewrite a bare pnpm typecheck (rtk rewrite "pnpm typecheck" exits 1).
Workarounds: rtk pnpm run typecheck (runs the real script, exit code 2 kept) or rtk proxy pnpm typecheck.
Activity
pszymkowiak commentedon Jul 4, 2026
🔍 Automated Triage
bugmediumSummary
rtk's command-rewrite logic incorrectly maps
pnpm typechecktopnpm tsc/tscinstead of passing through to the package.json script (e.g.turbo run typecheck); fix the pnpm rewrite rule to respect custom script definitions.📁 Relevant files
src/rewrite/pnpm.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
EDM115 commentedon Jul 30, 2026
actually,
rtkshould use itstscfilter only if thetypecheckscript contains it.matching for that however can be complex :
tscwon't cut it since we can have env vars settscin the middle of the command can also be wrong, what if ourtypecheckcommand actually runstsc --noEmit; cd src/rust && cargo check --all-targets --all-features? command separators are also different based on platformstscalone might also be wrong, what if we callvue-tsc? or run atsc.shfile that does some stuff before calling itselfpnpm exec tsc?KuSh commentedon Sep 12, 2026
Adding evidence found while reviewing #3676, which would have made this fire by default for every user rather than only for people who explicitly type
rtk pnpm typecheck.There is a write side effect that isn't in the original report: the dropped
--noEmitcauses tsc to emit compiled JavaScript into the project.main.rs:2096dispatchesPnpmCommands::Typechecktotsc_cmd::run(Some("pnpm"), &args, …), which runstscwith only the args aftertypecheck. For a barepnpm typecheckthat list is empty, so every flag the script carried — including--noEmit— is lost.Reproduced on current
develop(79b96a4), real project,"typecheck": "tsc --noEmit",tsconfig.jsonwithoutDir: "./dist":A read-only type check acquires a write side effect. On a project whose
typecheckscript is not tsc at all, the same path turned exit 0 with 1392 bytes of real output into exit 1 with a fabricatedTypeScript: No errors found.Other shapes broken by the same mechanism, beyond the Turborepo case in the report:
"typecheck": "vue-tsc --noEmit"/svelte-check— the wrong binary runs; for.vue/.sveltethe result is meaningless"typecheck": "tsc -b"— project-references build, not a plain check"typecheck": "tsc -p tsconfig.app.json"— the defaulttsconfig.jsonis checked instead, so a green result is a false pass over a different file settsconfig.json— baretscerrors wherepnpm typecheckwould have fanned out to workspacestscnot onPATH—tool_exec(…, MissingTool::Fetch)pulls TypeScript from the networkTwo possible fixes, depending on what
rtk pnpm typecheckis meant to be:PnpmCommands::Typecheckactually runpnpm typecheckand filter the tsc-shaped output it produces, keeping the script as the source of truth; orTypecheckvariant entirely and let it fall through toPnpmCommands::Other→ passthrough, the waytest/build/formatalready do.Option 2 is the smaller change and matches what the other script names already do. Option 1 keeps the filtering benefit but has to stop assuming the script is tsc.
Either way the
validate_pnpm_filtersFIXME inmain.rsis standing evidence that this delegation was already known to be lossy.Jayllyz commentedon Nov 27, 2026
Another repro, on a project where the
typecheckscript does not usetscat all andtscis not installed.Environment
package.json
Expected (
rtk proxy pnpm typecheck)Actual (
rtk pnpm typecheck)Impact
pnpm exec tscinstead.rtk pnpm typecheckform. The hook does not rewrite a barepnpm typecheck(rtk rewrite "pnpm typecheck"exits 1).Workarounds:
rtk pnpm run typecheck(runs the real script, exit code 2 kept) orrtk proxy pnpm typecheck.