Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,32 @@ async function load(resolveFrom: string, options, logger): Promise<PathMapType>
return result;
}

async function loadConfig(options, resolveFrom) {
async function loadConfigByName(names, options, resolveFrom) {
let result = await loadConfigUtil(
options.inputFS,
resolveFrom,
['tsconfig.json', 'tsconfig.js'],
names,
options.projectRoot
);
if (!result?.config) {
throw new Error(`Missing or invalid tsconfig.json in project root (${options.projectRoot})`);
throw new Error(`Missing or invalid ${names.join(',')} in project root (${options.projectRoot})`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add space after comma

}
return result.config;
}

async function loadConfig(options, resolveFrom) {
let baseConfig = await loadConfigByName(['tsconfig.json', 'tsconfig.js'], options, resolveFrom)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of this variable is ambiguous. I suggest childConfig for this line and parentConfig in place of extendsConfig

if (!baseConfig.extends) {
return baseConfig
}
let extendsConfig = await loadConfigByName([baseConfig.extends], options, resolveFrom)

return {
...baseConfig,
...extendsConfig
}
}

/** Populate a map with any paths from tsconfig.json starting from baseUrl */
async function loadTsPaths(resolveFrom: string, options, logger): Promise<PathMapType> {
let config = await loadConfig(options, resolveFrom);
Expand Down