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

isProgramUptoDate wrongfully returns true #36010

Closed
yacinehmito opened this issue Jan 5, 2020 · 0 comments · Fixed by #36011
Closed

isProgramUptoDate wrongfully returns true #36010

yacinehmito opened this issue Jan 5, 2020 · 0 comments · Fixed by #36011
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@yacinehmito
Copy link
Contributor

TypeScript Version: On master (commit d6c05a135840dc3045ec8f3bbec1da5ffabb6593)

Search Terms: isProgramUptoDate, synchronize program update program.

Code

I was playing around with the TypeScript API and I noticed that if you update the root files of a watcher program with the same number of root files, the source files are not updated.

import * as ts from 'typescript';

const watchHost = ts.createWatchCompilerHost(['path/to/foo']);
const program = ts.createWatchProgram(watchHost);
console.log(const program.getProgram().getSourceFiles()); // <- This has the expected sources
program.updateRootFileNames(['/path/to/bar']);
console.log(const program.getProgram().getSourceFiles()); // <- This has the same source, but it shouldn't

Expected behavior:

The source files should be the expected ones (so include /path/to/bar).

Actual behavior:

The source files didn't change.

Playground Link: Can't reproduce in the playground as it's an API bug.

Related Issues: Didn't find any related issues.


This is the culprit:

if (program.getRootFileNames().length !== rootFileNames.length) {

It should check for array equality, not just array length. I'll make a PR real soon.

@yacinehmito yacinehmito changed the title isProgramUptoDate wrongfully returns true isProgramUptoDate wrongfully returns true Jan 5, 2020
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jan 8, 2020
@sheetalkamat sheetalkamat added Bug A bug in TypeScript Fix Available A PR has been opened for this issue and removed Needs Investigation This issue needs a team member to investigate its status. labels Jan 16, 2020
@sheetalkamat sheetalkamat added this to the TypeScript 3.8.1 milestone Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants