Skip to content

Commit 7c55b2f

Browse files
committed
fix: add defensive guard on child.aliases in collectChildNames
Stricli always provides aliases at runtime (empty array when none), but type it as optional and use ?? [] for defensive safety per Seer and BugBot review feedback.
1 parent 3df1287 commit 7c55b2f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/lib/list-command.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,14 @@ let _subcommandsByRoute: Map<string, Set<string>> | undefined;
341341
* Lazily walks the Stricli route map on first call. Uses `require()` to break
342342
* the circular dependency: list-command → app → commands → list-command.
343343
*/
344-
/** Entry shape returned by Stricli's getAllEntries() */
344+
/**
345+
* Entry shape returned by Stricli's getAllEntries().
346+
* `aliases` is always present at runtime (empty array when none),
347+
* but typed as optional for defensive safety.
348+
*/
345349
type RouteEntry = {
346350
name: { original: string };
347-
aliases: readonly string[];
351+
aliases?: readonly string[];
348352
target: unknown;
349353
};
350354

@@ -355,7 +359,7 @@ function collectChildNames(parent: {
355359
const names = new Set<string>();
356360
for (const child of parent.getAllEntries()) {
357361
names.add(child.name.original);
358-
for (const alias of child.aliases) {
362+
for (const alias of child.aliases ?? []) {
359363
names.add(alias);
360364
}
361365
}

0 commit comments

Comments
 (0)