Skip to content

Make handleDtsMayChangeOf void-returning #44322

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

Merged
merged 2 commits into from
Jun 11, 2021
Merged

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented May 28, 2021

Right now, it always returns false. This seems important, since otherwise it would stop graph traversals prematurely. It took me a while to figure that out though and I thought it might be clearer if it were simply void-returning.

I've kept the behavior the same, except in forEachReferencingModulesOfExportOfAffectedFile, where it seemed like never enqueueing new references was a mistake.

Right now, it always returns false.  This seems important, since
otherwise it would stop graph traversals prematurely.  It took me a
while to figure that out though and I thought it might be clearer if it
were simply void-returning.

I've kept the behavior the same, except in
`forEachReferencingModulesOfExportOfAffectedFile`, where it seemed like
never enqueueing new references was a mistake.
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 28, 2021
const result = fn(state, currentPath);
if (result && isChangedSignature(state, currentPath)) {
fn(state, currentPath);
if (isChangedSignature(state, currentPath)) {
const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath)!;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure never entering this branch was a bug.

const result = fn(state, currentPath);
if (result && isChangedSignature(state, currentPath)) {
fn(state, currentPath);
if (isChangedSignature(state, currentPath)) {
const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath)!;
queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no one objects, I'd kind of like to rename queue to "stack", since it's manipulated with push and pop.

As far as I can tell, it could only return `false`.
@amcasey
Copy link
Member Author

amcasey commented May 28, 2021

It's probably easier to review the commits separately.

@@ -549,13 +547,11 @@ namespace ts {
const seenFileAndExportsOfFile = new Set<string>();
// Go through exported modules from cache first
// If exported modules has path, all files referencing file exported from are affected
if (forEachEntry(state.currentAffectedFilesExportedModulesMap, (exportedModules, exportedFromPath) =>
forEachEntry(state.currentAffectedFilesExportedModulesMap, (exportedModules, exportedFromPath) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this queues files , shouldnt we stop here and not do next step.. its duplicated work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what it should do, but I believe this is just a clearer way to write what it already does do. I don't understand the code very well and may have missed a case where it does return true and exit early.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, I'm less confident in the second commit than the first. AFAICT, it could only return true if a recursive call to itself returned true and all of the recursive base cases returned false.

@sheetalkamat
Copy link
Member

FYI: OK i remembered why it was returning boolean instead of void. removeSemanticDiagnosticsOf had intent that if we have deleted everything, we dont need to iterate on files any more. But after we added emit for d.ts is also needed part of the equation we couldnt use that any more (because you may or may not copy semantic diagnostics per your builder options) so we couldnt break the loop like that and had to ensure to iterate through everything and thats where the returning true part was lost and hence not needed any more.

@amcasey amcasey merged commit cdd7ffd into microsoft:main Jun 11, 2021
@amcasey amcasey deleted the BuilderVoid branch June 11, 2021 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants