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

ttsc --watch updates compiled files which are typically not touched by vanilla tsc #90

Open
dko-slapdash opened this issue Apr 17, 2020 · 1 comment

Comments

@dko-slapdash
Copy link

dko-slapdash commented Apr 17, 2020

UPD: I thought it's related to --assumeChangesOnlyAffectDirectDependencies flag - https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/ - but it's not. Even without this flag, ttsc overwrites the files in dist/, although their compiled output and themselves are both not changed (and tsc doesn't touch such files in similar sutuations).

# package.json
{
  "dependencies": {
    "nodemon": "^2.0.3",
    "ttypescript": "^1.5.10",
    "typescript": "^3.8.3"
  }
}

# tsconfig.json
{
  "include": ["src"],
  "compilerOptions": {
    // "assumeChangesOnlyAffectDirectDependencies": true,
    "baseUrl": "src",
    "outDir": "dist"
  }
}

# src/a.ts
export function aaa(): string {
  return "aaa";
}

# src/b.ts
import { aaa } from "./a";
export function bbb(): string {
  return aaa() + "/bbb";
}

# src/c.ts
import { bbb } from "./b";
export function ccc(): string {
  return bbb() + "/ccc";
}

In console 1:

yarn install
yarn ttsc --watch

In console 2:

yarn nodemon -w dist --verbose --exec "sleep inf" | grep "files triggering change"

In console 3:

echo "// test" >> src/a.ts
# Just touching is not enough, we need the file content to change.

Expected result (and actually this is what vanilla yarn tsc --watch shows):

[nodemon] files triggering change check: dist/a.js

Actual result with ttsc:

[nodemon] files triggering change check: dist/a.js
[nodemon] files triggering change check: dist/b.js
[nodemon] files triggering change check: dist/c.js

P.S.
If it stops reproducing, run rm -rf dist/* before ttsc.

P.P.S
I can be that vanilla tsc also recompiles b.ts and c.ts on changes in a.ts, but just doesn't write them since the compiled output is not changed (and ttsc doesn't have this "content comparison"). But then, what about --assumeChangesOnlyAffectDirectDependencies flag? Is it supported by ttsc the same way as it's supported by tsc?

@dko-slapdash dko-slapdash changed the title ttsc --assumeChangesOnlyAffectDirectDependencies doesn't work ttsc --watch --assumeChangesOnlyAffectDirectDependencies doesn't work Apr 17, 2020
@dko-slapdash dko-slapdash changed the title ttsc --watch --assumeChangesOnlyAffectDirectDependencies doesn't work ttsc --watch updates compiled files which are typically not touched by vanilla tsc Apr 17, 2020
@dko-slapdash
Copy link
Author

Here is a GitHub repo with repro: https://github.com/dko-slapdash/ttsc-watch-issue

# all 3 files in dist/ are updated
yarn test-ttsc
echo "// test" >> src/a.ts

# vanilla tsc; only 1 file in dist/ is updated
yarn test-tsc
echo "// test" >> src/a.ts

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

No branches or pull requests

2 participants