InferCoerce
typetype InferCoerce = T extends { coerce?: (v: any) => infer R }
? [R] extends [never]
? TFallback
: R extends undefined
? TFallback
: R
: TFallback;Infer the coerced type. If coerce function exists, use its return type.
Otherwise fall back to the provided fallback type.
Uses optional property matching coerce?: to handle configs where coerce
is defined as optional (like ObjectOptionConfig).
Special handling:
- [R] extends [never]: When coerce is missing/undefined, R infers as never
- R extends undefined: When coerce explicitly returns undefined