Skip to content

npm run tsc rewritten to rtk tsc drops --noEmit, emits .js/.map artifacts #1811

Closed as duplicate

Description

@HubertBiyo

Summary

When ~/.claude/settings.json registers rtk hook claude as a Bash PreToolUse hook, the command npm run tsc (where package.json has "tsc": "tsc --noEmit") is rewritten to rtk tsc — silently dropping the --noEmit flag carried by the npm script. TypeScript then emits .js / .jsx / .map files alongside source files, polluting the working tree.

Environment

  • RTK version: rtk 0.37.2
  • OS: Windows 10 (Git Bash)
  • TypeScript project (Umi/Max), tsconfig.json has "sourceMap": true, no noEmit set
  • package.json script: "tsc": "tsc --noEmit"

Reproduction

# In any TS project where tsconfig has no noEmit:true and package.json
# defines "tsc": "tsc --noEmit"

# 1) Direct invocation — correct (no emit)
./node_modules/.bin/tsc --noEmit
ls src/utils/request.js   # not found ✓

# 2) Through RTK hook (npm run tsc) — emits files
npm run tsc
ls src/utils/request.js   # exists ✗

# Inspect the hook decision:
echo '{"tool_name":"Bash","tool_input":{"command":"npm run tsc"}}' | rtk hook claude
# → {"updatedInput":{"command":"rtk tsc"}}    ← original command discarded

Root cause (two interacting issues)

  1. Hook rewrites npm run X blindly. The hook sees tsc and rewrites the whole invocation to rtk tsc, discarding the npm run context that would have resolved to tsc --noEmit via package.json.
  2. rtk tsc does not pass --noEmit by default. The subcommand's help says "TypeScript compiler with grouped error output", suggesting type-check-only, but the underlying tsc invocation respects tsconfig defaults — emitting files.

Impact

  • 787 stray .js / .jsx / .map files generated in a real project run
  • git status polluted with hundreds of untracked files
  • Required .gitignore workaround to prevent recurrence
  • Will affect any user whose npm script relies on --noEmit

Suggested fix

  • Option A (preferred): Don't rewrite npm run X at all. The npm script is the source of truth; let it resolve via package.json.
  • Option B: When the matched binary appears inside npm run …, preserve the full npm run invocation (e.g. rewrite to rtk proxy npm run X).
  • Option C: Have rtk tsc default to --noEmit, since the subcommand is documented as for "error output" only.

A combination of A + C would be most robust.

Workaround

src/**/*.js
src/**/*.jsx
src/**/*.js.map
src/**/*.jsx.map
config/**/*.js
config/**/*.js.map

Or use rtk proxy npm run tsc to bypass the rewrite.

Activity

  1. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 88%

    Summary

    Hook silently rewrites npm run tsc to rtk tsc, dropping --noEmit defined in package.json script body, causing 787+ unwanted JS/map file emissions — related to #2094 (pnpm) and #2098 (npm workspace flags), same root cause but distinct impact vector


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

  2. KuSh commented on Sep 5, 2026

    @KuSh
    Collaborator

    Closing as a duplicate of #2094, which tracks the same problem with the more complete discussion. Please follow up there; if your case differs in a way that issue does not cover, comment here and it can be reopened.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions