Skip to content

typecheck-tests.mjs treats the repo root as a package when run bare, and the new ignore hides it #3362

Description

@louistrue

node scripts/typecheck-tests.mjs run with cwd = the repo root silently treats the repository as a package and writes a 1,501-file typecheck program to /tsconfig.tests.json. Nothing refuses it.

What happens

parseCliMode treats zero arguments as valid package mode, so the bare invocation falls into checkOnePackage(process.cwd()) and then writeTestProgram(REPO_ROOT). Measured: a 1,515-line, 90 KB file listing 1,501 test files, and an OK line naming the repo directory as though it were a package.

This is the #2664 misuse the script's own header documents. parseCliMode already rejects the argument form of the same mistake; the cwd form has no equivalent guard.

Why it matters more now

Until #3350's follow-up, the stray untracked file in git status was the only visible trace that someone had run it wrong. That PR adds /tsconfig.tests.json to .gitignore — correctly, because once the file is tracked, every branch that adds or removes a test file carries a spurious ~1.5k-line diff and those conflict between branches.

But the ignore line removes the last visible symptom. After it, the misuse is silent: no stray file, no error, just an OK line. Absence now reads as success.

Proposed fix

A pkgDir === REPO_ROOT refusal in checkOnePackage, as the sibling of the guard parseCliMode already has. That turns the misuse into a stated error instead of an artifact, and makes the ignore line purely about diff noise rather than about hiding a hole.

How this was found

During review of the #3350 follow-up. The reviewer's own words: it "ignores the artifact of a misuse rather than refusing the misuse". Accepted as out of scope for a citation commit, filed so the underlying hole is not lost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions