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

Stale errors in tsbuildinfo file #42769

Closed
dko-slapdash opened this issue Feb 11, 2021 · 4 comments · Fixed by #48600
Closed

Stale errors in tsbuildinfo file #42769

dko-slapdash opened this issue Feb 11, 2021 · 4 comments · Fixed by #48600
Assignees
Labels
Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@dko-slapdash
Copy link

dko-slapdash commented Feb 11, 2021

It's gonna be a not well-structured bugreport unfortunately, since the effect is hard to reproduce. I hope it's already tracked somewhere (or maybe even addressed).

There is a monorepo with 2 project (say, shared/ and client/), and client/src/a.ts references a string union type T = "aa" | "bb" in shared/src/t.ts which is changed frequently. The two projects build independently, so basically client/a.ts references shared/dist/t.d.ts file (i.e. a.ts references *.d.ts in shared/).

Often times after adding a new alternative to T and using it in client/, when building client/, we see a compilation errors saying that this alternative is not in type T ("Argument of type T is not assignable ..."), although it's there, and shared/dist/t.d.ts is correct too.

  1. I opened client/dist/tsconfig.tsbuildinfo in a text error, and I see this error there.
  2. I manually edited this error in tsconfig.tsbuildinfo file (semanticDiagnosticsPerFile), and the output of ttsc --watch in client/ changed accordingly - i.e. I proved that tsc reads this error from tsconfig.tsbuildinfo and skips compilation for some reason.
  3. shared/dist/t.d.ts is correct. I tried to touch shared/dist/t.d.ts - no luck. I also tried to change its content manually (added a comment) - no luch too (which is weird: the content changed, so the checksum changed too; why didn't tsc notice that?).
  4. It looks like that if I remove the error objects from semanticDiagnosticsPerFile section of tsconfig.tsbuildinfo, the build succeeds.

I.e. it looks like while building client/, tsc for some reason ignores the checksums rechecking in tsconfig.tsbuildinfo and instead just throws the same error it threw before.

What resolves this error is following: if I rename shared/dist/t.d.ts.BAK, then rerun tsc --watch for client and see the new errors, then rename it back - then the error disappears.

Is it an issue in tsc somewhere? Or maybe there is a way to clean all the stale errors in tsbuildinfo file to make sure tsc --watch doesn't rely on them?

P.S.
skipLibCheck=true, composite=true (but shared/ is built independently, no references), incremental=true, declaration=true

Could you please provide some more details on how semanticDiagnosticsPerFile works and how does it recheck the files for changes? Because there is definitely a change in t.d.ts file, and this file is mentioned inside the list of files in semanticDiagnosticsPerFile, but despite of that change, tsc still throws the stale error.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Feb 12, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.3.0 milestone Feb 12, 2021
@sheetalkamat
Copy link
Member

Please provide concrete repro steps with source code and changes that need to be followed step by step rather than just describing the issue. Without steps its hard to understand whats going on and whats expected.

@sheetalkamat sheetalkamat added Needs More Info The issue still hasn't been fully clarified and removed Needs Investigation This issue needs a team member to investigate its status. labels Mar 2, 2021
@dko-slapdash
Copy link
Author

@sheetalkamat That’s the problem, I can’t provide any repro steps, the effect is extremely unstable. Maybe you could provide some hints/guesses at least, how does the described behavior look like, knowing how it works internally?

@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Jun 18, 2021
@lukeapage
Copy link

We get something similiar. We cannot share the repo it happens in - its 800k lines of proprietary code. I delete the cache and then the error disappears. In our case its always generics. In case it helps this is the most recent case:

[ts:watch-frontend] <redacted>/selectors.ts:241:9 - error TS2769: No overload matches this call.
[ts:watch-frontend]   The last overload gave the following error.
[ts:watch-frontend]     Argument of type 'OutputParametricSelector<State, string, Dictionary<Instrument>, (res1: Dictionary<Instrument>, res2: Dictionary<
Instrument>, res3: any) => Dictionary<...>>' is not assignable to parameter of type 'ParametricSelector<unknown, unknown, InstrumentGroupItems | null | un
defined>[]'.
[ts:watch-frontend]       Type 'OutputParametricSelector<State, string, Dictionary<Instrument>, (res1: Dictionary<Instrument>, res2: Dictionary<Instrument
>, res3: any) => Dictionary<...>>' is missing the following properties from type 'ParametricSelector<unknown, unknown, InstrumentGroupItems | null | undef
ined>[]': pop, push, concat, join, and 28 more.
[ts:watch-frontend]
[ts:watch-frontend] 241         createGetInstrumentsData(),
[ts:watch-frontend]             ~~~~~~~~~~~~~~~~~~~~~~~~~~
[ts:watch-frontend]
[ts:watch-frontend]   node_modules/reselect/lib/index.d.ts:960:17
[ts:watch-frontend]     960 export function createSelector<S, P, R, T>(
[ts:watch-frontend]                         ~~~~~~~~~~~~~~
[ts:watch-frontend]     The last overload is declared here.

Without giving you the whole source code, is there any way to help define what the issue is?

@adrienharnay
Copy link

Hello @sheetalkamat , I believe the problem I am facing today is the same as this issue, and I have a very simple reproduction for it: https://github.com/adrienharnay/typescript-buildinfo-bug-repro

sheetalkamat added a commit that referenced this issue Apr 7, 2022
…, everything needs update in signature and dts emit

Fixes #42769
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 7, 2022
@sheetalkamat sheetalkamat removed the Needs More Info The issue still hasn't been fully clarified label Apr 7, 2022
sheetalkamat added a commit that referenced this issue Apr 11, 2022
…, everything needs update in signature and dts emit

Fixes #42769
sheetalkamat added a commit that referenced this issue Apr 11, 2022
…, everything needs update in signature and dts emit

Fixes #42769
sheetalkamat added a commit that referenced this issue Apr 13, 2022
…, everything needs update in signature and dts emit

Fixes #42769
sheetalkamat added a commit that referenced this issue Apr 14, 2022
…, everything needs update in signature and dts emit

Fixes #42769
sheetalkamat added a commit that referenced this issue Apr 14, 2022
…, everything needs update in signature and dts emit

Fixes #42769
sheetalkamat added a commit that referenced this issue Apr 19, 2022
…, everything needs update in signature and dts emit

Fixes #42769
sheetalkamat added a commit that referenced this issue Apr 19, 2022
…, everything needs update in signature and dts emit

Fixes #42769
sheetalkamat added a commit that referenced this issue Apr 21, 2022
…, everything needs update in signature and dts emit (#48600)

* Add test

* Renames

* More refactoring

* If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit
Fixes #42769
Jack-Works pushed a commit to Jack-Works/TypeScript that referenced this issue Apr 22, 2022
…, everything needs update in signature and dts emit (microsoft#48600)

* Add test

* Renames

* More refactoring

* If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit
Fixes microsoft#42769
sheetalkamat added a commit that referenced this issue Jun 8, 2022
* Use fixed time for vfs so baselining is consistent

* Baseline buildinfos

* Write new file text in baseline even if the file wasnt read on the shadow

* Remove unnecessary debugger statement

* Make sure that incremental correctness is checked with correct writeFile so we know buildInfo was written
Also baseline these so its easy to verify the changes

* More baselines for the tsbuildinfo

* If we are writing dts file and have used file text as version, we can update the signature when doing actual emit

* Make WriteFileCallback Api ready for future

* Assert that there is only single source file when emitting d.ts file

* Add test

* Renames

* More refactoring

* If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit
Fixes #42769

* Stacktrace optimization for getModified time in anticipation of using it more than fileExists wherever possible

* Baseline getModifiedTime, setModifiedTime, fileExits and directoryExits for experiment

* Remove unnecessary write file finger print code since its not used at all

* Use modified time instead of file existence check

* Remove unnecessary getModifiedTime

* No need to check for file existence before reading the d.ts file

* Do project reference errors before doing input/output file checks

* Dont call getModifiedTimes if dts change

* Passdown modified time if queried

* Use modified time passed through the file watching in tsbuild

* Handle force build as separate upto date status

* uptodate status worker to read buildinfo and use it to determine upto date ness

* No need to update output timestamps if buildinfo will determine uptodateness

* Store change file set instead of hasPendingChange to be able to reuse the information

* Add test that shows input file is not present

* No need to check input time stamp before buildinfo

* Keep buildinfos for lifetime of the solution builder and project

* Store modified time along with text of buildinfo

* Non composite projects dont need to track declaration change time

* Pass through buildInfo so we dont have to parse it back

* Save dts change time in buildinfo itself

* Store dts time for --out in the buildInfo

* Store hash of text in the bundle info so it can be verified before manipulating text for fast updates during prepend
This helps when text changes during incremental build toggling and we determine we can just manipulate text

* Since buildinfo is cached no need to maintain version check state

* Store output time stamps for non incremental builds

* Revert "Baseline getModifiedTime, setModifiedTime, fileExits and directoryExits for experiment"

This reverts commit 7e65cd3.

* Change verbose messages for upto date status

* Reconcile reusable builder state and builder state so there are not two different types that are almost similar looking

* Cleanup impliedFormat

* Cleanup

* Cleanup noEmit option

* BuildInfo options emit as a flag

* Factor out types for program written in buildinfo with and without bundle emit

* No need to store output file stamps if not in watch mode

* Cleanup

* Test for single watch per file

* Fix emit and error update baselines that were duplicate

* More refactoring

* Only copy emit state fields when backing up to restore if emit fails

* Instead of maintaining delta of changes, maintain old state for those changes

* Add test to verify build when input file does not change

* If version of the input file does not change, dont mark as out of date

* Disable lint warning as build fails without the assert

* Report aggregate statistics for solution as well as some solution perf numbers

* Options solutionDiagnostics instead so that its not too verbose when printing diagnostics

* When tsc --build --clean, only remove tsbuildinfo if its incremental build

* Revert "Options solutionDiagnostics instead so that its not too verbose when printing diagnostics"

This reverts commit 0cf9e30.

* Revert "Report aggregate statistics for solution as well as some solution perf numbers"

This reverts commit 405d8e9.

* Revert "When tsc --build --clean, only remove tsbuildinfo if its incremental build"

This reverts commit e4e6672.

* Comments in the code

* Feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
7 participants