MCPcopy Create free account
hub / github.com/chakra-ui/panda / resolveSolutionTsconfigForFile

Function resolveSolutionTsconfigForFile

packages/node/src/tsconfig-utils.ts:99–135  ·  view source on GitHub ↗
(
  absoluteFilename: string,
  rootTsconfigPath: string,
  rootParsed: TsConfigJsonResolved,
  getTsconfigModule: typeof import('get-tsconfig'),
)

Source from the content-addressed store, hash-verified

97 * return that project's merged tsconfig for `compilerOptions`.
98 */
99export 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

Callers 1

loadTsConfigFunction · 0.90

Calls 3

dirnameMethod · 0.65

Tested by

no test coverage detected