Skip to content

Commit b3cb7db

Browse files
committed
Initialize the map for dts to reference and source to reference when parsing project reference as its always needed
1 parent 81c9518 commit b3cb7db

File tree

9 files changed

+95
-132
lines changed

9 files changed

+95
-132
lines changed

src/compiler/builderState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export namespace BuilderState {
206206
* Gets the path to reference file from file name, it could be resolvedPath if present otherwise path
207207
*/
208208
function getReferencedFileFromFileName(program: Program, fileName: string, sourceFileDirectory: Path, getCanonicalFileName: GetCanonicalFileName): Path {
209-
return toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
209+
return toPath(program.getRedirectFromSourceFile(fileName)?.outputDts || fileName, sourceFileDirectory, getCanonicalFileName);
210210
}
211211

212212
/**

src/compiler/checker.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4719,7 +4719,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
47194719
);
47204720
}
47214721
else if (resolvedModule.resolvedUsingTsExtension && shouldRewrite) {
4722-
const redirect = host.getResolvedProjectReferenceToRedirect(sourceFile.path);
4722+
const redirect = host.getRedirectFromSourceFile(sourceFile.path)?.resolvedRef;
47234723
if (redirect) {
47244724
const ignoreCase = !host.useCaseSensitiveFileNames();
47254725
const ownRootDir = host.getCommonSourceDirectory();
@@ -4814,9 +4814,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
48144814
if (moduleNotFoundError) {
48154815
// See if this was possibly a projectReference redirect
48164816
if (resolvedModule) {
4817-
const redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
4818-
if (redirect) {
4819-
error(errorNode, Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
4817+
const redirect = host.getRedirectFromSourceFile(resolvedModule.resolvedFileName);
4818+
if (redirect?.outputDts) {
4819+
error(errorNode, Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect.outputDts, resolvedModule.resolvedFileName);
48204820
return undefined;
48214821
}
48224822
}
@@ -41530,7 +41530,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4153041530
) {
4153141531
Debug.assert(!!(type.symbol.flags & SymbolFlags.ConstEnum));
4153241532
const constEnumDeclaration = type.symbol.valueDeclaration as EnumDeclaration;
41533-
const redirect = host.getRedirectReferenceForResolutionFromSourceOfProject(getSourceFileOfNode(constEnumDeclaration).resolvedPath);
41533+
const redirect = host.getRedirectFromOutput(getSourceFileOfNode(constEnumDeclaration).resolvedPath)?.resolvedRef;
4153441534
if (constEnumDeclaration.flags & NodeFlags.Ambient && !isValidTypeOnlyAliasUseSite(node) && (!redirect || !shouldPreserveConstEnums(redirect.commandLine.options))) {
4153541535
error(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
4153641536
}
@@ -48184,7 +48184,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4818448184
targetFlags & SymbolFlags.ConstEnum
4818548185
) {
4818648186
const constEnumDeclaration = target.valueDeclaration as EnumDeclaration;
48187-
const redirect = host.getRedirectReferenceForResolutionFromSourceOfProject(getSourceFileOfNode(constEnumDeclaration).resolvedPath);
48187+
const redirect = host.getRedirectFromOutput(getSourceFileOfNode(constEnumDeclaration).resolvedPath)?.resolvedRef;
4818848188
if (constEnumDeclaration.flags & NodeFlags.Ambient && (!redirect || !shouldPreserveConstEnums(redirect.commandLine.options))) {
4818948189
error(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
4819048190
}
@@ -53374,7 +53374,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host: TypeCheckerHo
5337453374
getPackageJsonInfoCache: () => host.getPackageJsonInfoCache?.(),
5337553375
useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
5337653376
redirectTargetsMap: host.redirectTargetsMap,
53377-
getProjectReferenceRedirect: fileName => host.getProjectReferenceRedirect(fileName),
53377+
getRedirectFromSourceFile: fileName => host.getRedirectFromSourceFile(fileName),
5337853378
isSourceOfProjectReferenceRedirect: fileName => host.isSourceOfProjectReferenceRedirect(fileName),
5337953379
fileExists: fileName => host.fileExists(fileName),
5338053380
getFileIncludeReasons: () => host.getFileIncludeReasons(),

src/compiler/moduleSpecifiers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ export function forEachFileNameOfModule<T>(
719719
): T | undefined {
720720
const getCanonicalFileName = hostGetCanonicalFileName(host);
721721
const cwd = host.getCurrentDirectory();
722-
const referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
722+
const referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getRedirectFromSourceFile(importedFileName)?.outputDts : undefined;
723723
const importedPath = toPath(importedFileName, cwd, getCanonicalFileName);
724724
const redirects = host.redirectTargetsMap.get(importedPath) || emptyArray;
725725
const importedFileNames = [...(referenceRedirect ? [referenceRedirect] : emptyArray), importedFileName, ...redirects];

0 commit comments

Comments
 (0)