From bee7f78b8a1a6481197cbd075b0bffdd0bb27f4d Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 1 Oct 2025 11:21:03 -0700 Subject: [PATCH] take issue to throw on --- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/program.ts | 7 ++++++- src/compiler/types.ts | 4 ++++ src/compiler/utilities.ts | 5 ----- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 9cdda68f67d..aa738c6f75d 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1673,7 +1673,7 @@ function tryLoadModuleUsingBaseUrl(extensions: Extensions, moduleName: string, l trace(state.host, Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate); } const res = loader(extensions, candidate, !directoryProbablyExists(getDirectoryPath(candidate), state.host), state); - if (res) { + if (res && state.compilerOptions.issueType === "baseUrl") { throw new Error("TS_FIX_BASEURL_SIGNAL"); } return res; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3b9b3a60761..663f49247c0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -315,7 +315,6 @@ import { trace, tracing, tryCast, - tsFixRootDirSignal, TypeChecker, typeDirectiveIsEqualTo, TypeReferenceDirectiveResolutionCache, @@ -2149,6 +2148,12 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro return ts_toPath(fileName, currentDirectory, getCanonicalFileName); } + function tsFixRootDirSignal(kind: string, rootDir: string, rootDir60: string): void { + if (options.issueType === "rootDir") { + throw new Error(`TS_FIX_ROOTDIR_SIGNAL:: ${kind}:: 5.9:: ${rootDir} 6.0:: ${rootDir60} `); + } + } + function getCommonSourceDirectory() { let commonSourceDirectory = programDiagnostics.getCommonSourceDirectory(); if (commonSourceDirectory !== undefined) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ee7f4338a3a..0c0f3acec96 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7395,7 +7395,11 @@ export enum PollingWatchKind { export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; // eslint-disable-line no-restricted-syntax +/** @internal */ +export type IssueType = "baseUrl" | "rootDir" | "types"; + export interface CompilerOptions { + /** @internal */ issueType?: IssueType; /** @internal */ all?: boolean; allowImportingTsExtensions?: boolean; allowJs?: boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 51871749158..397c949410b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6628,11 +6628,6 @@ export function sourceFileMayBeEmitted(sourceFile: SourceFile, host: SourceFileM return true; } -/**@internal */ -export function tsFixRootDirSignal(kind: string, rootDir: string, rootDir60: string): void { - throw new Error(`TS_FIX_ROOTDIR_SIGNAL:: ${kind}:: 5.9:: ${rootDir} 6.0:: ${rootDir60} `); -} - /** @internal */ export function sourceFileMayBeEmitted60(sourceFile: SourceFile, host: SourceFileMayBeEmittedHost, forceDtsEmit?: boolean): boolean { const options = host.getCompilerOptions();