Skip to content

npx tsc -w is triggering itself after each build #64037

Open

Description

🔎 Search Terms

No amount of exclude or watchOptions seems to have any impact.

I am outputting my JavaScript files along side my TS files, which is what I want, I don't know why it keeps retriggering itself

Output looks like this

> npx tsc --watch --extendedDiagnostics
[08:05:29 PM] Starting compilation in watch mode...

[08:05:29 PM] Found 0 errors. Watching for file changes.

[08:05:29 PM] File change detected. Starting incremental compilation...

[08:05:30 PM] Found 0 errors. Watching for file changes.

[08:05:30 PM] File change detected. Starting incremental compilation...

[08:05:31 PM] Found 0 errors. Watching for file changes.

[08:05:31 PM] File change detected. Starting incremental compilation...

[08:05:31 PM] Found 0 errors. Watching for file changes.

[08:05:32 PM] File change detected. Starting incremental compilation...

[08:05:32 PM] Found 0 errors. Watching for file changes.

npx tsc --showConfig doesn't show any watchOptions not sure if they are getting picked up

🕗 Version & Regression Information

"name": "@typescript/typescript-win32-x64",
"version": "7.0.2",

⏯ Playground Link

No response

💻 Code

No response

🙁 Actual behavior

tsc -w triggers itself in a loop

🙂 Expected behavior

tsc -w doesn't triggers itself in a loop

Additional information about the issue

No response

Activity

  1. msab-john commented on Aug 26, 2026

    @msab-john
    Author

    Ha, I figured out what it was!

    It was wgo, I had this thing https://github.com/bokwoon95/wgo watching for changes to my Go programs. Once I stopped these it started working. Maybe you want to look in to that, because I don't think they should be interfering with each other. I don't know what wgo is doing but if it is causing events that trigger tsc needlessly that wrong?

  2. msab-john commented on Aug 26, 2026

    @msab-john
    Author

    No, I don't think anything is wrong here. wgo is updating a file in the same directory regardless of any changes, I suspect this is triggering tsc, which is understandable.

    How can I get it to ignore this file? It's a *.wasm file

    This doesn't seem to the trick

    {
      "compilerOptions": {
        "types": ["node"],
        "jsx": "react-jsx",
        "jsxImportSource": "preact",
        "module": "nodenext",
        "moduleResolution": "nodenext",
        "target": "esnext",
        "strict": true
      },
      "include": ["**/*.ts"],
      "exclude": ["**/*.js", "**/*.js.map", "**/*.d.ts", "**/*.wasm"],
      "watchOptions": {
        "excludeFiles": ["**/*.js", "**/*.js.map", "**/*.d.ts", "**/*.wasm"],
        "excludeDirectories": ["**/node_modules"]
      }
    }
  3. RyanCavanaugh commented on Aug 26, 2026

    @RyanCavanaugh
    Member

    We need a concrete repro in order to investigate

  4. msab-john commented on Aug 27, 2026

    @msab-john
    Author

    I'll see if I can make a small and simple one...

  5. nstepien commented on Sep 3, 2026

    @nstepien

    Experiencing the same issue.

    Very simple repro:

    • run tsc --watch --preserveWatchOutput
    • create a directory at the root
    • tsc will detect the new directory and trigger a re-run

      File change detected. Starting incremental compilation...

    This does not happen if I create a new file at the root, or create a new file in the newly created directory, or delete the newly created directory.
    For example

    /tsconfig.json
    /bogus/ <- new directory, triggers compilation despite not being included in tsconfigs
               deleting it does not trigger compilation
    /bogus/bogus.ts <- new file, no issues
    /bogus.ts <- new file, no issues
    

    I should add that TS7's watch mode does not offer any way afaict to log which file/folder triggered a re-run.

  6. njmarsh commented on Oct 5, 2026

    @njmarsh

    I have a repro below on 7.0.2 (macOS, fsevents backend).

    I'm pretty sure it's the same issue as the original report: in watch mode, any write under a recursive include root triggers a rebuild. exclude is ignored.

    Expected: no rebuild for writes under excluded directories. 6.0.3 with the same project compiles once at startup and doesn't react to build/ writes.

    repro/
    ├── src/index.ts        // export const a = 1;
    └── tsconfig.json
    
    // tsconfig.json
    {
      "compilerOptions": { "noEmit": true, "incremental": true, "tsBuildInfoFile": "./build/tsconfig.tsbuildinfo" },
      "include": ["**/*"],
      "exclude": ["build"]
    }
    

    Running TS_WATCH_DEBUG=1 tsc --watch --preserveWatchOutput produces:

    Starting compilation in watch mode...
    [watch] watching directory /repro (recursive=true)
    Found 0 errors. Watching for file changes.
    
    [watch] 2 event(s): update /repro/build, update /repro/build/tsconfig.tsbuildinfo
    File change detected. Starting incremental compilation...        // triggered by its own tsbuildinfo
    Found 0 errors. Watching for file changes.
    

    Further updates to files under repro/build produce similar rebuilds, despite the exclude statement.

    For anyone else debugging this: TS_WATCH_DEBUG=1 logs the event paths that trigger each rebuild.

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

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions