Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript build in watch mode does not compile newly created files or renamed files #37514

Open
tuan231195 opened this issue Mar 22, 2020 · 5 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@tuan231195
Copy link

TypeScript Version: : 3.9.0-dev.20200322, 3.8.3

Search Terms: build, project references, watch mode

Code

  • Run project in build and watch mode: tsc -b -w -v
  • Adding a new file to one of the project references. The new file is not detected by the watch process and hence not compiled
  • Rename an existing file in the project. The compilation fails with error:
    File 'filename' not found.

Expected behavior:

New files and renamed files are compiled correctly

Actual behavior:

New files were not compiled. Renamed files caused the compilation to fail

Playground Link: https://github.com/RyanCavanaugh/project-references-demo

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 22, 2020
@sheetalkamat
Copy link
Member

This does not repro as you mentioned. We would need detail steps to repro the issue along with sample code to see if something is wrong.


c:\temp\project-references-demo>node c:\TypeScript\built\local\tsc.js -b -v -w --preserveWatchOutput --listFiles --listEmittedFiles
[1:21:26 PM] Starting compilation in watch mode...

[1:21:26 PM] Projects in this build:
    * core/tsconfig.json
    * animals/tsconfig.json
    * zoo/tsconfig.json
    * tsconfig.json

[1:21:26 PM] Project 'core/tsconfig.json' is out of date because output file 'lib/core/utilities.js' does not exist

[1:21:26 PM] Building project 'c:/temp/project-references-demo/core/tsconfig.json'...

TSFILE: c:/temp/project-references-demo/lib/core/utilities.js
TSFILE: c:/temp/project-references-demo/lib/core/utilities.d.ts
TSFILE: c:/temp/project-references-demo/lib/core/tsconfig.tsbuildinfo
c:/TypeScript/built/local/lib.d.ts
c:/TypeScript/built/local/lib.es5.d.ts
c:/TypeScript/built/local/lib.dom.d.ts
c:/TypeScript/built/local/lib.webworker.importscripts.d.ts
c:/TypeScript/built/local/lib.scripthost.d.ts
c:/temp/project-references-demo/core/utilities.ts
[1:21:27 PM] Project 'animals/tsconfig.json' is out of date because output file 'lib/animals/animal.js' does not exist

[1:21:27 PM] Building project 'c:/temp/project-references-demo/animals/tsconfig.json'...

TSFILE: c:/temp/project-references-demo/lib/animals/animal.js
TSFILE: c:/temp/project-references-demo/lib/animals/animal.d.ts
TSFILE: c:/temp/project-references-demo/lib/animals/index.js
TSFILE: c:/temp/project-references-demo/lib/animals/index.d.ts
TSFILE: c:/temp/project-references-demo/lib/animals/dog.js
TSFILE: c:/temp/project-references-demo/lib/animals/dog.d.ts
TSFILE: c:/temp/project-references-demo/lib/animals/tsconfig.tsbuildinfo
c:/TypeScript/built/local/lib.d.ts
c:/TypeScript/built/local/lib.es5.d.ts
c:/TypeScript/built/local/lib.dom.d.ts
c:/TypeScript/built/local/lib.webworker.importscripts.d.ts
c:/TypeScript/built/local/lib.scripthost.d.ts
c:/temp/project-references-demo/animals/animal.ts
c:/temp/project-references-demo/animals/index.ts
c:/temp/project-references-demo/lib/core/utilities.d.ts
c:/temp/project-references-demo/animals/dog.ts
[1:21:28 PM] Project 'zoo/tsconfig.json' is out of date because output file 'lib/zoo/zoo.js' does not exist

[1:21:28 PM] Building project 'c:/temp/project-references-demo/zoo/tsconfig.json'...

TSFILE: c:/temp/project-references-demo/lib/zoo/zoo.js
TSFILE: c:/temp/project-references-demo/lib/zoo/zoo.d.ts
TSFILE: c:/temp/project-references-demo/lib/zoo/tsconfig.tsbuildinfo
c:/TypeScript/built/local/lib.d.ts
c:/TypeScript/built/local/lib.es5.d.ts
c:/TypeScript/built/local/lib.dom.d.ts
c:/TypeScript/built/local/lib.webworker.importscripts.d.ts
c:/TypeScript/built/local/lib.scripthost.d.ts
c:/temp/project-references-demo/lib/animals/animal.d.ts
c:/temp/project-references-demo/lib/animals/dog.d.ts
c:/temp/project-references-demo/lib/animals/index.d.ts
c:/temp/project-references-demo/zoo/zoo.ts
[1:21:29 PM] Found 0 errors. Watching for file changes.

[1:21:43 PM] File change detected. Starting incremental compilation...

[1:21:43 PM] Project 'animals/tsconfig.json' is out of date because oldest output 'lib/animals/animal.js' is older than newest input 'core'

[1:21:43 PM] Building project 'c:/temp/project-references-demo/animals/tsconfig.json'...

TSFILE: c:/temp/project-references-demo/lib/animals/newfile.js
TSFILE: c:/temp/project-references-demo/lib/animals/newfile.d.ts
TSFILE: c:/temp/project-references-demo/lib/animals/tsconfig.tsbuildinfo
c:/TypeScript/built/local/lib.d.ts
c:/TypeScript/built/local/lib.es5.d.ts
c:/TypeScript/built/local/lib.dom.d.ts
c:/TypeScript/built/local/lib.webworker.importscripts.d.ts
c:/TypeScript/built/local/lib.scripthost.d.ts
c:/temp/project-references-demo/animals/animal.ts
c:/temp/project-references-demo/animals/index.ts
c:/temp/project-references-demo/lib/core/utilities.d.ts
c:/temp/project-references-demo/animals/dog.ts
c:/temp/project-references-demo/animals/newfile.ts
[1:21:43 PM] Updating unchanged output timestamps of project 'c:/temp/project-references-demo/animals/tsconfig.json'...

[1:21:44 PM] Project 'zoo/tsconfig.json' is out of date because oldest output 'lib/zoo/zoo.js' is older than newest input 'animals/tsconfig.json'

[1:21:44 PM] Building project 'c:/temp/project-references-demo/zoo/tsconfig.json'...

c:/TypeScript/built/local/lib.d.ts
c:/TypeScript/built/local/lib.es5.d.ts
c:/TypeScript/built/local/lib.dom.d.ts
c:/TypeScript/built/local/lib.webworker.importscripts.d.ts
c:/TypeScript/built/local/lib.scripthost.d.ts
c:/temp/project-references-demo/lib/animals/animal.d.ts
c:/temp/project-references-demo/lib/animals/dog.d.ts
c:/temp/project-references-demo/lib/animals/index.d.ts
c:/temp/project-references-demo/zoo/zoo.ts
[1:21:44 PM] Updating unchanged output timestamps of project 'c:/temp/project-references-demo/zoo/tsconfig.json'...

[1:21:44 PM] Found 0 errors. Watching for file changes.

[1:22:02 PM] File change detected. Starting incremental compilation...

[1:22:02 PM] Project 'animals/tsconfig.json' is out of date because oldest output 'lib/animals/animal.js' is older than newest input 'core'

[1:22:02 PM] Building project 'c:/temp/project-references-demo/animals/tsconfig.json'...

animals/index.ts:4:32 - error TS2307: Cannot find module './dog' or its corresponding type declarations.

4 import { createDog, Dog } from './dog';
                                 ~~~~~~~

c:/TypeScript/built/local/lib.d.ts
c:/TypeScript/built/local/lib.es5.d.ts
c:/TypeScript/built/local/lib.dom.d.ts
c:/TypeScript/built/local/lib.webworker.importscripts.d.ts
c:/TypeScript/built/local/lib.scripthost.d.ts
c:/temp/project-references-demo/animals/animal.ts
c:/temp/project-references-demo/animals/index.ts
c:/temp/project-references-demo/lib/core/utilities.d.ts
c:/temp/project-references-demo/animals/dog2.ts
c:/temp/project-references-demo/animals/newfile.ts
[1:22:02 PM] Found 1 error. Watching for file changes.

@sheetalkamat sheetalkamat added the Needs More Info The issue still hasn't been fully clarified label Mar 23, 2020
@sheetalkamat sheetalkamat removed their assignment Mar 23, 2020
@sheetalkamat sheetalkamat removed the Needs Investigation This issue needs a team member to investigate its status. label Mar 23, 2020
@dko-slapdash
Copy link

dko-slapdash commented Oct 31, 2022

@sheetalkamat @RyanCavanaugh
This issue has been with us for at least 2 years; we're waiting so much until it's resolved, but it doesn't hapen. I understand that it may be super-hard to repro in a sandbox, but still, attaching a screencast showing the effect of this bug hoping that it would help to hint, what's going on.

Reproducible in BOTH VSCode editor (!!!) and in tsc --watch. I.e. it's not an artifact of our build system (which includes many components), it affects vanilla VSCode's TS server process running in noEmit mode too.

Below is one screencast split into 3 videos (one after another).

Configuration:

  1. slapdash-server-ingestion monorepo project is compiled with a separate tsc --watch process with incremental=true
  2. slapdash-server monorepo project (depends on the previous) is compiled with tsc --watch with emitDeclarationOnly=true and incremental=true

Basically, on the videos, the files appeared in node_modules/slapdash-server-ingestion/dist/.../ are not picked up by the watching tsc in slapdash-server (node_modules/slapdash-server-ingestion is a lerna-symlink to packages/slapdash-server-ingestion).

What I do there (in time order):

  1. I have several tsc --watch processes running, and then I check out a version from Git which has new TS files (dist/.../FactAllAclsOfAssetAre.ts) appeared in slapdash-server-ingestion monorepo project (compiled with a separate tsc --watch process).
  2. tsc --watch of slapdash-server-ingestion compiles the new files (FactAllAclsOfAssetAre.ts) into dist/ folder. But then, from within slapdash-server monorepo project (from within slapdash-server/.../FactAllAclsOfAssetAre.test.ts on the 1st video), the compilation result (dist/.../FactAllAclsOfAssetAre.d.ts) is not visible: e.g. VSCode red-underlines the file as missing (although it's there), and tsc --watch for slapdash-server doesn't see the file too.

Now an interesting part

  1. Re-saving FactAllAclsOfAssetAre.test.ts (without modifying it) does NOT help. See the bottom of the 1st video which records the keystrokes. It doesn't help in both VSCode and in tsc --watch which compiles FactAllAclsOfAssetAre.test.ts.
  2. What's interesting is that, if I do a dummy change in import directive in FactAllAclsOfAssetAre.test.ts and then revert it, all without saving (video 2), it helps VSCode to find the file (but it obviously doesn't let tsc --watch unstuck). It looks like there is some cache in the watching process which is not refreshed even on a file change, and the only time when it's refreshed is when that particular import statement changes.
  3. Only when I do a dummy change in FactAllAclsOfAssetAre.test.ts in that import statement AND SAVE IT, then revert the change and save again, it unsticks tsc --watch for that file only.
  4. I have to repeat the same procedure (open a stuck file, apply a dummy change in import statement (not in any other parts of the code! exactly in that import statement!) to fully unstuck all of the files eventually (video 3).
CleanShot.2022-10-30.at.17.43.26.mp4
CleanShot.2022-10-30.at.17.44.28.mp4
CleanShot.2022-10-30.at.17.55.04.mp4

@mayzenator
Copy link

hi! any updates on this thread? seeing the same issue

@adriana47
Copy link

Same issue, on webstorm. Changing tsconfig.json include/exclude patterns isn't helping. Editing and reverting the import statement is the only workaround so far, but not a fix. Can this be looked at please?

@aakash14goplani
Copy link

Facing same issue with SvelteKit + Turbo Monorepo setup.

There are two ways to reproduce this:

  1. Move file from one package to another.
  2. Rename file with change in case e.g. AakashFile to aakashFile

Run the localhost now, it will forever load...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

7 participants