Strip index-signature keys from a type, keeping only concrete known keys.
This prevents Record<PropertyKey, CallableFunction> (from the Methods
constraint) from leaking an index signature into Guarded<M>, which would
make any property access (e.g. exo.nonExistentMethod) silently resolve
to CallableFunction instead of being a type error.
Special cases:
When T is any, pass through unchanged (avoids collapsing to {}).
When T has only index-signature keys and no concrete keys (e.g. bare
Methods from untyped JS), pass through unchanged so that property
access still works.
When T has concrete keys mixed with an index signature (e.g.
{ incr: ... } & Methods), strip the index signature and keep only
the concrete keys.
Strip index-signature keys from a type, keeping only concrete known keys. This prevents
Record<PropertyKey, CallableFunction>(from theMethodsconstraint) from leaking an index signature intoGuarded<M>, which would make any property access (e.g.exo.nonExistentMethod) silently resolve toCallableFunctioninstead of being a type error.Special cases:
Tisany, pass through unchanged (avoids collapsing to{}).Thas only index-signature keys and no concrete keys (e.g. bareMethodsfrom untyped JS), pass through unchanged so that property access still works.Thas concrete keys mixed with an index signature (e.g.{ incr: ... } & Methods), strip the index signature and keep only the concrete keys.