Skip to content

Commit b3e991e

Browse files
authored
Fix Omit to preserve readonly and optionality attributes
microsoft/TypeScript#13224 (comment)
1 parent e6d5043 commit b3e991e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ function typeOfExpression() {};
6666
* My addition, OmitFromInterface<T, U> is like Omit except it omits the *properties* of the second type, so U is an interface as well.
6767
*/
6868
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];
69-
type Omit<T, K extends keyof T> = {[P in Diff<keyof T, K>]: T[P]};
69+
type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
7070
type OmitInterface<T, U> = Omit<T, keyof U>;
7171
```

0 commit comments

Comments
 (0)