Don't add ambiently declared modules to ATA's unresolvedModules list#20464
Conversation
|
N.B. from issue
This turns out to be insufficient - even after excluding The prior fix in #20403 is sufficient in cases where an ambient module is declared in the location where we would find it if it were a proper module, but doesn't fix the case where it's simply ambient in a random location. The simple additional fix here (which doesn't per se exclude the other one, because the other fix improves performance) is to ask for the list of ambient modules from the checker and exclude them. |
| const resolutionToFile = getResolvedModule(oldProgramState.oldSourceFile, moduleName); | ||
| const resolvedFile = resolutionToFile && oldProgramState.program && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); | ||
| if (resolutionToFile && !resolvedFile.externalModuleIndicator) { | ||
| // module used to be resolved to module - ignore it |
There was a problem hiding this comment.
The comment here says that the module use to be resolved to module and yet we check !resolvedFile.externalModuleIndicator?
There was a problem hiding this comment.
This is for the case where we previously resolved to a module that ultimately contained an ambient declaration for the module we were looking for, but isn't actually itself the module. In that case we can't "re-use" the resolution.
There was a problem hiding this comment.
That makes sense, can you please update the comment.
| abstract getTypeAcquisition(): TypeAcquisition; | ||
|
|
||
| protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition { | ||
| if (!newTypeAcquisition || !newTypeAcquisition.include) { |
There was a problem hiding this comment.
Is this right? if (!something) return something always reads a bit fishy.
75fab46 to
c154705
Compare
Fixes #20402
Builds on #20403; only the last commit is new relative to that one