MCPcopy Create free account
hub / github.com/cevek/ttypescript / getConfig

Function getConfig

packages/ttypescript/src/patchCreateProgram.ts:115–138  ·  view source on GitHub ↗
(
    tsm: typeof ts,
    compilerOptions: ts.CompilerOptions,
    rootFileNames: ReadonlyArray<string>,
    defaultDir: string
)

Source from the content-addressed store, hash-verified

113}
114
115function getConfig(
116 tsm: typeof ts,
117 compilerOptions: ts.CompilerOptions,
118 rootFileNames: ReadonlyArray<string>,
119 defaultDir: string
120) {
121 if (compilerOptions.configFilePath === undefined) {
122 const dir = rootFileNames.length > 0 ? dirname(rootFileNames[0]) : defaultDir;
123 const tsconfigPath = tsm.findConfigFile(dir, tsm.sys.fileExists);
124 if (tsconfigPath) {
125 const projectDir = dirname(tsconfigPath);
126 const config = readConfig(tsm, tsconfigPath, dirname(tsconfigPath));
127 compilerOptions = { ...config.options, ...compilerOptions };
128 return {
129 projectDir,
130 compilerOptions,
131 };
132 }
133 }
134 return {
135 projectDir: dirname(compilerOptions.configFilePath as string),
136 compilerOptions,
137 };
138}
139
140function readConfig(tsm: typeof ts, configFileNamePath: string, projectDir: string) {
141 const result = tsm.readConfigFile(configFileNamePath, tsm.sys.readFile);

Callers 1

createProgramFunction · 0.85

Calls 1

readConfigFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…