Skip to content

Commit

Permalink
chore: update index
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 15, 2023
1 parent 259f9e5 commit 17b520b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.ja.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.ko.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.zh-CN.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions questions/28143-hard-optionalundefined/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!--info-header-start--><h1>OptionalUndefined <img src="https://img.shields.io/badge/-hard-de3d37" alt="hard"/> </h1><blockquote><p>by Jesus The Hun <a href="https://github.com/JesusTheHun" target="_blank">@JesusTheHun</a></p></blockquote><p><a href="https://tsch.js.org/28143/play" target="_blank"><img src="https://img.shields.io/badge/-Take%20the%20Challenge-3178c6?logo=typescript&logoColor=white" alt="Take the Challenge"/></a> </p><!--info-header-end-->

Implement the util type `OptionalUndefined<T, Props>` that turns all the properties of `T` that can be `undefined`, into optional properties. In addition, a second -optional- generic `Props` can be passed to restrict the properties that can be altered.

```ts
Expand All @@ -7,3 +9,6 @@ OptionalUndefined<{ value: string | undefined, description: string }>
OptionalUndefined<{ value: string | undefined, description: string | undefined, author: string | undefined }, 'description' | 'author'>
// { value: string | undefined; description?: string | undefined, author?: string | undefined }
```


<!--info-footer-start--><br><a href="../../README.md" target="_blank"><img src="https://img.shields.io/badge/-Back-grey" alt="Back"/></a> <a href="https://tsch.js.org/28143/answer" target="_blank"><img src="https://img.shields.io/badge/-Share%20your%20Solutions-teal" alt="Share your Solutions"/></a> <a href="https://tsch.js.org/28143/solutions" target="_blank"><img src="https://img.shields.io/badge/-Check%20out%20Solutions-de5a77?logo=awesome-lists&logoColor=white" alt="Check out Solutions"/></a> <!--info-footer-end-->
8 changes: 4 additions & 4 deletions questions/28143-hard-optionalundefined/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { ExpectFalse, NotEqual } from '@type-challenges/utils'
type cases = [
Expect<Equal<OptionalUndefined<{ value: string | undefined }, 'value'>, { value?: string | undefined }>>,
Expect<Equal<OptionalUndefined<{ value: string; desc: string }, 'value'>, { value: string; desc: string }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined, desc: string }, 'value'>, { value?: string; desc: string }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined, desc: string | undefined }, 'value'>, { value?: string | undefined; desc: string | undefined }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined, desc: string }, 'value' | 'desc'>, { value?: string; desc: string }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined, desc: string | undefined }>, { value?: string; desc?: string }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined; desc: string }, 'value'>, { value?: string; desc: string }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined; desc: string | undefined }, 'value'>, { value?: string | undefined; desc: string | undefined }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined; desc: string }, 'value' | 'desc'>, { value?: string; desc: string }>>,
Expect<Equal<OptionalUndefined<{ value: string | undefined; desc: string | undefined }>, { value?: string; desc?: string }>>,
Expect<Equal<OptionalUndefined<{ value?: string }, 'value'>, { value?: string }>>,
Expect<Equal<OptionalUndefined<{ value?: string }>, { value?: string }>>,
]

0 comments on commit 17b520b

Please sign in to comment.