You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(deps-resolver): make WantedDependency.alias optional to match aliasless deps #33
The WantedDependency interface declares alias: string (required), but aliasless wanted dependencies exist at runtime — e.g. pnpm add jsr:@x/y, a bare owner/repo#sha, or a GitHub URL, where parseWantedDependency returns no alias. Today these are produced by casting (parseWantedDependencies does ... as WantedDependency[]), so the type doesn't reflect reality and any test/fixture that builds an aliasless wanted dependency is forced into an as unknown as WantedDependency cast.
This was raised by an automated reviewer on pnpm/pnpm#11373; that PR centralized the new test casts into a single helper but did not change the interface, since the proper fix has a broad ripple (see below).
Proposed change
Make alias optional on the wanted-dependency type(s) so the type matches runtime, and remove the casts at the parse seam and in fixtures.
Why it's non-trivial (blast radius)
Flipping alias to optional in pnpm11/installing/deps-resolver/src/getNonDevWantedDependencies.ts produces 7 type errors in deps-resolver alone (resolveDependencies.ts, toResolveImporter.ts), where call sites assume alias is a non-null string (map keys, indexing, comparisons).
There are two separate WantedDependency interfaces — getNonDevWantedDependencies.ts and getWantedDependencies.ts — both declaring alias: string, consumed across deps-resolver, deps-installer, and command packages. They should likely be unified as part of this.
Scope
Decide whether to unify the two WantedDependency interfaces.
Make alias optional and fix the call sites that assume it is present (guard, or narrow where an alias is guaranteed).
Activity
fix(deps-resolver): allow wanted dependencies without an alias (#16245)