export const omit = <T, U extends keyof T>(obj: T, keys: U[]): Exclude<T, U> =>
Object.keys(obj).reduce(
(acc: any, curr: any) => (keys.includes(curr) ? acc : { ...acc, [curr]: obj[curr] }),
{}
);
收到一条错误消息说明 TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'unknown'.
并希望没有错误消息和正确键入的函数。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句