Skip to content

Commit 3fc40cc

Browse files
ralyodioclaude
andcommitted
fix(resolve): unbreak the build — narrow parseRegistryName's destructured parts
CI has been red on main since #48: noUncheckedIndexedAccess types the destructured `label`/`tld` as `string | undefined`, because TS can't narrow an array to a 2-tuple from a `parts.length !== 2` check. Four TS2345/TS2322 errors failed `apps/desktop` and took the whole `pnpm -r build` with it. Guard explicitly. Behavior is unchanged: length 2 already guarantees both values, and an empty label would fail LABEL.test() on the next line anyway. Unrelated to this branch's auth work, but it blocks the PR from going green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 5eabb6d commit 3fc40cc

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

apps/desktop/src/moshpit-resolve.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ export function parseRegistryName(hostname: string): { label: string; tld: strin
112112
const parts = host.split('.');
113113
if (parts.length !== 2) return null;
114114
const [label, tld] = parts;
115+
// `parts.length !== 2` above already guarantees both exist, but
116+
// noUncheckedIndexedAccess types them as `string | undefined` — TS can't
117+
// narrow an array to a 2-tuple from a length check. An empty label would
118+
// fail LABEL.test() anyway, so this guard changes no behavior.
119+
if (!label || !tld) return null;
115120
const LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
116121
if (!LABEL.test(label) || !LABEL.test(tld)) return null;
117122
return { label, tld };

0 commit comments

Comments
 (0)