Skip to content

Commit 0743b29

Browse files
committed
feat: add 0059-hard-get-optional
1 parent dde965d commit 0743b29

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type GetOptional<T> = {
2+
[K in keyof T as T[K] extends Required<T>[K] ? never : K]: T[K];
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { Equal, Expect } from "@type-challenges/utils";
2+
3+
type cases = [
4+
Expect<Equal<GetOptional<{ foo: number; bar?: string }>, { bar?: string }>>,
5+
Expect<
6+
Equal<GetOptional<{ foo: undefined; bar?: undefined }>, { bar?: undefined }>
7+
>
8+
];

0 commit comments

Comments
 (0)