Skip to content

Commit

Permalink
Simplify required keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Mar 2, 2022
1 parent 615a326 commit 363937b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,10 @@ export namespace objectUtil {
[k in keyof T]: undefined extends T[k] ? k : never;
}[keyof T];

type requiredKeys<T extends object> = Exclude<keyof T, optionalKeys<T>>;
// type requiredKeys<T extends object> = Exclude<keyof T, optionalKeys<T>>;
type requiredKeys<T extends object> = {
[k in keyof T]: undefined extends T[k] ? never : k;
}[keyof T];

export type addQuestionMarks<T extends object> = {
[k in optionalKeys<T>]?: T[k];
Expand Down
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,10 @@ export namespace objectUtil {
[k in keyof T]: undefined extends T[k] ? k : never;
}[keyof T];

type requiredKeys<T extends object> = Exclude<keyof T, optionalKeys<T>>;
// type requiredKeys<T extends object> = Exclude<keyof T, optionalKeys<T>>;
type requiredKeys<T extends object> = {
[k in keyof T]: undefined extends T[k] ? never : k;
}[keyof T];

export type addQuestionMarks<T extends object> = {
[k in optionalKeys<T>]?: T[k];
Expand Down

0 comments on commit 363937b

Please sign in to comment.