Avoid unnecessary resolution-mode assertion in declaration emit (#55727)

This commit is contained in:
Andrew Branch
2023-09-13 13:31:19 -07:00
committed by GitHub
parent b9b5d16bd5
commit 07bca994fa
5 changed files with 106 additions and 2 deletions

View File

@@ -47760,11 +47760,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function addReferencedFilesToTypeDirective(file: SourceFile, key: string, mode: ResolutionMode) {
if (fileToDirective.has(file.path)) return;
fileToDirective.set(file.path, [key, mode]);
for (const { fileName, resolutionMode } of file.referencedFiles) {
for (const { fileName } of file.referencedFiles) {
const resolvedFile = resolveTripleslashReference(fileName, file.fileName);
const referencedFile = host.getSourceFile(resolvedFile);
if (referencedFile) {
addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
// The resolution mode of the file reference doesn't actually matter here -
// all we're recording is the fact that the file entered the compilation
// transitively via a type reference directive of {key} with mode {mode}.
addReferencedFilesToTypeDirective(referencedFile, key, mode || file.impliedNodeFormat);
}
}
}