Skip to content

Commit 456ac87

Browse files
committed
fix(core): apply correct overload signatures for getEntriesFromCliOrConfig
1 parent 3455ecc commit 456ac87

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

packages/core/src/lib/cli/internal/get-entries-from-cli-or-config.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,23 @@ export type Entry<TEntry> = {
1313

1414
export const DEFAULT_PROJECT_NAME = 'default';
1515

16+
export function getEntriesFromCliOrConfig(
17+
entryFileOrEntryPoints?: string,
18+
): Array<Entry<ProjectInfo>>;
19+
export function getEntriesFromCliOrConfig(
20+
entryFileOrEntryPoints?: string,
21+
runInit?: true,
22+
): Array<Entry<ProjectInfo>>;
23+
export function getEntriesFromCliOrConfig(
24+
entryFileOrEntryPoints?: string,
25+
runInit?: false,
26+
): Array<Entry<string>>;
1627
export function getEntriesFromCliOrConfig(
1728
/**
1829
* the CLI forwards either the entry file e.g. "src/main.ts" or
1930
* the entry point(s) e.g. app-i,app-ii
2031
*/
21-
entryFileOrEntryPoints?: string,
32+
entryFileOrEntryPoints = '',
2233
runInit = true,
2334
): Array<Entry<string>> | Array<Entry<ProjectInfo>> {
2435
const fs = getFs();
@@ -30,9 +41,7 @@ export function getEntriesFromCliOrConfig(
3041
if (entryFileOrEntryPoints) {
3142
// CLI argument given and no config file is present -> only entry file can work
3243
if (!fs.exists(potentialConfigFile)) {
33-
return processEntryFile(entryFileOrEntryPoints as string, runInit, fs) as
34-
| Array<Entry<string>>
35-
| Array<Entry<ProjectInfo>>;
44+
return processEntryFile(entryFileOrEntryPoints as string, runInit, fs);
3645
}
3746

3847
if (fs.exists(potentialConfigFile)) {
@@ -46,14 +55,10 @@ export function getEntriesFromCliOrConfig(
4655

4756
if (potentialEntryPoints) {
4857
// if entry points are given, return them
49-
return processEntryFile(potentialEntryPoints, runInit, fs) as
50-
| Array<Entry<string>>
51-
| Array<Entry<ProjectInfo>>;
58+
return processEntryFile(potentialEntryPoints, runInit, fs);
5259
} else {
5360
// otherwise it is an entry file
54-
return processEntryFile(entryFileOrEntryPoints, runInit, fs) as
55-
| Array<Entry<string>>
56-
| Array<Entry<ProjectInfo>>;
61+
return processEntryFile(entryFileOrEntryPoints, runInit, fs);
5762
}
5863
}
5964
}
@@ -68,16 +73,12 @@ export function getEntriesFromCliOrConfig(
6873
}
6974

7075
if (sheriffConfig.entryFile) {
71-
return processEntryFile(sheriffConfig.entryFile, runInit, fs) as
72-
| Array<Entry<string>>
73-
| Array<Entry<ProjectInfo>>;
76+
return processEntryFile(sheriffConfig.entryFile, runInit, fs);
7477
} else if (
7578
sheriffConfig.entryPoints &&
7679
!isEmptyRecord(sheriffConfig.entryPoints)
7780
) {
78-
return processEntryFile(sheriffConfig.entryPoints, runInit, fs) as
79-
| Array<Entry<string>>
80-
| Array<Entry<ProjectInfo>>;
81+
return processEntryFile(sheriffConfig.entryPoints, runInit, fs);
8182
} else {
8283
throw new Error(
8384
'No entry file or entry points found in sheriff.config.ts. Please provide the option via the CLI.',
@@ -109,13 +110,13 @@ function processEntryFile(
109110
const entries = Object.entries(entryFileValue);
110111

111112
return runInit
112-
? entries.map(([projectName, entry]) => ({
113+
? (entries.map(([projectName, entry]) => ({
113114
projectName,
114115
entry: init(toFsPath(fs.join(fs.cwd(), entry as string))),
115-
}))
116-
: entries.map(([projectName, entry]) => ({
116+
})) as Array<Entry<ProjectInfo>>)
117+
: (entries.map(([projectName, entry]) => ({
117118
projectName,
118119
entry: entry as string,
119-
}));
120+
})) as Array<Entry<string>>);
120121
}
121122
}

0 commit comments

Comments
 (0)