Skip to content

tsc --watch doesn't pick up changes when the project is in a shallow folder like /app #64425

Description

@Generalsimus

🔎 Search Terms

tsc --watch not rebuilding, watch doesn't detect changes, docker, WORKDIR /app, no watchable ancestor

🕗 Version & Regression Information

  • This changed between versions @typescript/native-preview@7.0.0-dev.20260612.1 and 7.0.0-dev.20260613.1

I think it came in with microsoft/typescript-go#4026. It still happens on 7.0.2 and on today's nightly (7.1.0-dev.20260924.1). 6.0.3 works fine.

⏯ Playground Link

No response

💻 Code

mkdir /app && cd /app
echo '{"compilerOptions":{"outDir":"out"},"include":["*.ts"]}' > tsconfig.json
echo 'export const x = "AAA";' > a.ts
TS_WATCH_DEBUG=1 npx tsc --watch
# now edit a.ts

🙁 Actual behavior

The first build works, but after that nothing happens when I edit a.ts. No rebuild, no error. With TS_WATCH_DEBUG=1 it prints:

[watch] no watchable ancestor for /app

Same with tsc -b --watch. I hit this in Docker, where /app is a pretty common WORKDIR.

It's not only /app. In /srv/app nothing rebuilds either. In /usr/src/app or ~/project, files under src/ still rebuild, but files right in the project folder don't. That made it really confusing to track down.

🙂 Expected behavior

Edits get picked up, like in 6.0.3, or like in 7 when the project sits a bit deeper (/usr/src/app/server works fine).

Additional information about the issue

From what I can tell, CanWatchDirectory wants at least 5 path components, and it runs on every directory the watcher wants, including the project's own folders. In 6.0 the same check was only used for lookup locations (failed module lookups, package.json, @types), never for the project's files.

I have a fix up in #64366.

(I used an AI assistant to help write this up.)

Activity

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

Metadata

Metadata

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