Utility type that recursively ignores unknown string index properties on the given object.
We use this on the TSchema
type in validateStandardSchema
in order to accommodate Zod's
looseObject
which includes {[key: string]: unknown}
as part of the type.
API
type IgnoreUnknownProperties<T> = T extends Record<PropertyKey, unknown> ? { [K in keyof T as RemoveStringIndexUnknownKey<K, T[K]>]: IgnoreUnknownProperties<T[K]>; } : T
Jump to details