@@ -188,19 +188,41 @@ type WithFnsSeed<U> = {
188188 : WithFnsSeed < U [ K ] > ;
189189} ;
190190
191+ /** Var seeds only - the half of {@link WithSeed} that stays small in
192+ * declaration emit when the `use` fn override map is wide. */
193+ type WithVarsSeed < RV > = { [ K in keyof RV ] ?: RV [ K ] } ;
194+
191195/**
192196 * Flat `.with` seed map stored on exported fns. Evaluating ScopeOf /
193197 * ModuleFns here (instead of embedding those wrappers as type arguments)
194198 * keeps declaration emit small: `.d.ts` shows leaf var shapes and bound
195199 * call signatures, not `ScopeOf<ResolvedVars<entire module graph>>`.
200+ *
201+ * Declaration emit stores {@link WithSeedStored} on the fn (var seeds
202+ * only); terminating `.fn()` intersects a full {@link WithSeed} `.with`.
196203 */
197- export type WithSeed < RV , U > = Prettify <
198- { [ K in keyof RV ] ?: RV [ K ] } & WithFnsSeed < U >
199- > ;
204+ export type WithSeed < RV , U > = Prettify < WithVarsSeed < RV > & WithFnsSeed < U > > ;
205+
206+ /** What declaration emit stores for `W` - var seeds only so TS does not
207+ * inline `BoundFnCall` per used fn from the builder `use` graph. */
208+ export type WithSeedStored < RV , _U = unknown > = WithVarsSeed < RV > ;
200209
201- /** What `v.fn` / `e.fn` returns: contract params plus a flat { @link WithSeed}
210+ /** What `v.fn` / `e.fn` returns: contract params plus a stored seed map
202211 * for `.with`, never the raw ScopeOf / ModuleFns graph. */
203212export type PublicFn <
213+ A ,
214+ R ,
215+ K extends string ,
216+ I ,
217+ P extends readonly string [ ] ,
218+ Er ,
219+ W = unknown ,
220+ O = unknown ,
221+ > = FnDefination < A , R , K , I , P , Er , W , O > ;
222+
223+ /** Terminating `.fn()` product: compact {@link WithSeedStored} on the
224+ * fn for declaration emit, full {@link WithSeed} on `.with` while typing. */
225+ type TerminatingFn <
204226 A ,
205227 R ,
206228 K extends string ,
@@ -210,7 +232,9 @@ export type PublicFn<
210232 RV ,
211233 U ,
212234 O = unknown ,
213- > = FnDefination < A , R , K , I , P , Er , WithSeed < RV , U > , O > ;
235+ > = PublicFn < A , R , K , I , P , Er , WithSeedStored < RV , U > , O > & {
236+ with ( context : WithSeed < RV , U > ) : BoundCall < A , R , I , Er > ;
237+ } ;
214238
215239/** What `.with` returns: the same callable, context baked in.
216240 * Re-exported from the package entry so exporting `.with(...)` results
@@ -615,7 +639,7 @@ export interface Fn<
615639 Fn < Base , BaseFns , BasePL , Prefix >
616640 > ,
617641 ) => R ,
618- ) : PublicFn <
642+ ) : TerminatingFn <
619643 void ,
620644 R ,
621645 Prefix extends "" ? string : Prefix ,
@@ -636,7 +660,7 @@ export interface Fn<
636660 Fn < Base , BaseFns , BasePL , `${Prefix } ${K } `>
637661 > ,
638662 ) => R ,
639- ) : PublicFn <
663+ ) : TerminatingFn <
640664 void ,
641665 R ,
642666 `${Prefix } ${K } `,
@@ -675,7 +699,7 @@ export interface Fn<
675699 ChainPL < BasePL , PL >
676700 > ,
677701 ) => R ,
678- ) : PublicFn <
702+ ) : TerminatingFn <
679703 WidenedArgs < I , ChainPL < BasePL , PL > > ,
680704 R ,
681705 Prefix extends "" ? string : Prefix ,
@@ -716,7 +740,7 @@ export interface Fn<
716740 ChainPL < BasePL , PL >
717741 > ,
718742 ) => R ,
719- ) : PublicFn <
743+ ) : TerminatingFn <
720744 WidenedArgs < I , ChainPL < BasePL , PL > > ,
721745 R ,
722746 `${Prefix } ${K } `,
0 commit comments