mirror of
https://github.com/type-challenges/type-challenges.git
synced 2026-02-01 15:47:22 +00:00
Co-authored-by: Zheeeng <1303154+zheeeng@users.noreply.github.com>
This commit is contained in:
parent
d56905c5e8
commit
2e708a95cc
7
questions/59-hard-get-optional/README.md
Normal file
7
questions/59-hard-get-optional/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
Implement the advanced util type `GetOptional<T>`, which remains all the optional fields
|
||||
|
||||
For example
|
||||
|
||||
```ts
|
||||
type I = GetOptional<{ foo: number, bar?: string }> // expected to be { bar?: string }
|
||||
```
|
||||
7
questions/59-hard-get-optional/info.yml
Normal file
7
questions/59-hard-get-optional/info.yml
Normal file
@ -0,0 +1,7 @@
|
||||
difficulty: hard
|
||||
title: Get Optional
|
||||
tags: 'utils, infer'
|
||||
author:
|
||||
github: zheeeng
|
||||
name: Zheeeng
|
||||
|
||||
1
questions/59-hard-get-optional/template.ts
Normal file
1
questions/59-hard-get-optional/template.ts
Normal file
@ -0,0 +1 @@
|
||||
type GetOptional<T> = any
|
||||
6
questions/59-hard-get-optional/test-cases.ts
Normal file
6
questions/59-hard-get-optional/test-cases.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Equal, Expect, ExpectFalse, NotEqual } from '@type-challenges/utils'
|
||||
|
||||
type cases = [
|
||||
Expect<Equal<GetOptional<{ foo: number, bar?: string }>, { bar?: string }>>,
|
||||
Expect<Equal<GetOptional<{ foo: undefined, bar?: undefined }>, { bar?: undefined }>>,
|
||||
]
|
||||
Loading…
x
Reference in New Issue
Block a user