diff --git a/questions/59-hard-get-optional/README.md b/questions/59-hard-get-optional/README.md new file mode 100644 index 00000000..cf35b64c --- /dev/null +++ b/questions/59-hard-get-optional/README.md @@ -0,0 +1,7 @@ +Implement the advanced util type `GetOptional`, which remains all the optional fields + +For example + +```ts +type I = GetOptional<{ foo: number, bar?: string }> // expected to be { bar?: string } +``` diff --git a/questions/59-hard-get-optional/info.yml b/questions/59-hard-get-optional/info.yml new file mode 100644 index 00000000..49152359 --- /dev/null +++ b/questions/59-hard-get-optional/info.yml @@ -0,0 +1,7 @@ +difficulty: hard +title: Get Optional +tags: 'utils, infer' +author: + github: zheeeng + name: Zheeeng + diff --git a/questions/59-hard-get-optional/template.ts b/questions/59-hard-get-optional/template.ts new file mode 100644 index 00000000..f5699f99 --- /dev/null +++ b/questions/59-hard-get-optional/template.ts @@ -0,0 +1 @@ +type GetOptional = any diff --git a/questions/59-hard-get-optional/test-cases.ts b/questions/59-hard-get-optional/test-cases.ts new file mode 100644 index 00000000..b1ecd1d9 --- /dev/null +++ b/questions/59-hard-get-optional/test-cases.ts @@ -0,0 +1,6 @@ +import { Equal, Expect, ExpectFalse, NotEqual } from '@type-challenges/utils' + +type cases = [ + Expect, { bar?: string }>>, + Expect, { bar?: undefined }>>, +]