loadTSConfig() — astro Function Reference
Architecture documentation for the loadTSConfig() function in tsconfig.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD a6e37a03_5a26_695d_8c86_4bb714f0e372["loadTSConfig()"] 1275993c_9183_58e3_869f_4f9529e67337["tsconfig.ts"] a6e37a03_5a26_695d_8c86_4bb714f0e372 -->|defined in| 1275993c_9183_58e3_869f_4f9529e67337 e5f6e523_9490_ddc2_e291_acd5c2238c39["safeParse()"] a6e37a03_5a26_695d_8c86_4bb714f0e372 -->|calls| e5f6e523_9490_ddc2_e291_acd5c2238c39 style a6e37a03_5a26_695d_8c86_4bb714f0e372 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/config/tsconfig.ts lines 65–113
export async function loadTSConfig(
root: string | undefined,
findUp = false,
): Promise<TSConfigResult<{ rawConfig: TSConfig }>> {
const safeCwd = root ?? process.cwd();
const [jsconfig, tsconfig] = await Promise.all(
['jsconfig.json', 'tsconfig.json'].map((configName) =>
// `tsconfck` expects its first argument to be a file path, not a directory path, so we'll fake one
find(join(safeCwd, './dummy.txt'), {
root: findUp ? undefined : root,
configName: configName,
}),
),
);
// If we have both files, prefer tsconfig.json
if (tsconfig) {
const parsedConfig = await safeParse(tsconfig, { root: root });
if (typeof parsedConfig === 'string') {
return parsedConfig;
}
// tsconfck does not return the original config, so we need to parse it ourselves
// https://github.com/dominikg/tsconfck/issues/138
const rawConfig = await readFile(tsconfig, 'utf-8')
.then(toJson)
.then((content) => JSON.parse(content) as TSConfig);
return { ...parsedConfig, rawConfig };
}
if (jsconfig) {
const parsedConfig = await safeParse(jsconfig, { root: root });
if (typeof parsedConfig === 'string') {
return parsedConfig;
}
const rawConfig = await readFile(jsconfig, 'utf-8')
.then(toJson)
.then((content) => JSON.parse(content) as TSConfig);
return { ...parsedConfig, rawConfig: rawConfig };
}
return 'missing-config';
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does loadTSConfig() do?
loadTSConfig() is a function in the astro codebase, defined in packages/astro/src/core/config/tsconfig.ts.
Where is loadTSConfig() defined?
loadTSConfig() is defined in packages/astro/src/core/config/tsconfig.ts at line 65.
What does loadTSConfig() call?
loadTSConfig() calls 1 function(s): safeParse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free