Skip to content

Commit

Permalink
fix(omit): type
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Oct 24, 2018
1 parent 6ffd174 commit caa60f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/omit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import forOwn from './forOwn'

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>

/**
* 创建一个从 obj 中剔除选中的属性的对象。
*
Expand All @@ -10,8 +12,8 @@ import forOwn from './forOwn'
export default function omit<
T extends object,
K extends keyof T
>(obj: T, props: K[]): Pick<T, K> {
const newObj: Pick<T, K> = {} as any
>(obj: T, props: K[]): Omit<T, K> {
const newObj: Omit<T, K> = {} as any
forOwn(obj, (value, key) => {
if (props.indexOf(key as any) === -1) {
(newObj as any)[key] = value
Expand Down

0 comments on commit caa60f4

Please sign in to comment.