fix(compiler-cli): Return original sourceFile instead of redirected sourceFile from getSourceFile (#26036)
Closes #22524 PR Close #26036
This commit is contained in:

committed by
Matias Niemelä

parent
40705f3366
commit
3166cffd28
@ -39,6 +39,13 @@ export class TypeCheckProgramHost implements ts.CompilerHost {
|
||||
sf = this.delegate.getSourceFile(
|
||||
fileName, languageVersion, onError, shouldCreateNewSourceFile);
|
||||
sf && this.sfMap.set(fileName, sf);
|
||||
} else {
|
||||
// TypeScript doesn't allow returning redirect source files. To avoid unforseen errors we
|
||||
// return the original source file instead of the redirect target.
|
||||
const redirectInfo = (sf as any).redirectInfo;
|
||||
if (redirectInfo !== undefined) {
|
||||
sf = redirectInfo.unredirected;
|
||||
}
|
||||
}
|
||||
return sf;
|
||||
}
|
||||
|
@ -441,6 +441,12 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
|
||||
fileName, summary.text, this.options.target || ts.ScriptTarget.Latest);
|
||||
}
|
||||
sf = summary.sourceFile;
|
||||
// TypeScript doesn't allow returning redirect source files. To avoid unforseen errors we
|
||||
// return the original source file instead of the redirect target.
|
||||
const redirectInfo = (sf as any).redirectInfo;
|
||||
if (redirectInfo !== undefined) {
|
||||
sf = redirectInfo.unredirected;
|
||||
}
|
||||
genFileNames = [];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user