(
absoluteFilename: string,
rootTsconfigPath: string,
rootParsed: TsConfigJsonResolved,
getTsconfigModule: typeof import('get-tsconfig'),
)
| 97 | * return that project's merged tsconfig for `compilerOptions`. |
| 98 | */ |
| 99 | export async function resolveSolutionTsconfigForFile( |
| 100 | absoluteFilename: string, |
| 101 | rootTsconfigPath: string, |
| 102 | rootParsed: TsConfigJsonResolved, |
| 103 | getTsconfigModule: typeof import('get-tsconfig'), |
| 104 | ): Promise<{ tsconfig: TsConfigJsonResolved; tsconfigFile: string }> { |
| 105 | const { parseTsconfig } = getTsconfigModule |
| 106 | |
| 107 | if (isSourceFileIncludedInTsconfig(absoluteFilename, rootTsconfigPath, rootParsed)) { |
| 108 | return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath } |
| 109 | } |
| 110 | |
| 111 | const refs = rootParsed.references |
| 112 | if (!refs?.length) { |
| 113 | return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath } |
| 114 | } |
| 115 | |
| 116 | if (!SOURCE_EXTENSIONS.some((ext) => absoluteFilename.endsWith(ext))) { |
| 117 | return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath } |
| 118 | } |
| 119 | |
| 120 | const rootDir = path.dirname(rootTsconfigPath) |
| 121 | for (const ref of refs) { |
| 122 | const refPath = resolveReferencedTsconfigPath(ref.path, rootDir) |
| 123 | try { |
| 124 | await fs.access(refPath) |
| 125 | } catch { |
| 126 | continue |
| 127 | } |
| 128 | const childParsed = parseTsconfig(refPath) |
| 129 | if (isSourceFileIncludedInTsconfig(absoluteFilename, refPath, childParsed)) { |
| 130 | return { tsconfig: childParsed, tsconfigFile: refPath } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath } |
| 135 | } |
| 136 | |
| 137 | // --------------------------------------------------------------------------- |
| 138 | // Tsconfig include/exclude/files matching |
no test coverage detected