forked from type-challenges/type-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(question): add type-challenges#28333 - Public Type (type-challen…
…ges#28334) Co-authored-by: KaiKai <99722991+kaikaibenkai@users.noreply.github.com>
- Loading branch information
1 parent
f0da15b
commit f77d878
Showing
4 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove the key starting with `_` from given type `T`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
difficulty: medium | ||
title: Public Type | ||
tags: object-keys | ||
author: | ||
github: kaikaibenkai | ||
name: KaiKai | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type PublicType<T extends object> = any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Equal, Expect } from '@type-challenges/utils' | ||
|
||
type cases = [ | ||
Expect<Equal<PublicType<{ a: number }>, { a: number }>>, | ||
Expect<Equal<PublicType<{ _b: string | bigint }>, {}>>, | ||
Expect<Equal<PublicType<{ readonly c?: number }>, { readonly c?: number }>>, | ||
Expect<Equal<PublicType<{ d: string, _e: string }>, { d: string }>>, | ||
Expect<Equal<PublicType<{ _f: () => bigint[] }>, {}>>, | ||
Expect<Equal<PublicType<{ g: `_g` }>, { g: `_g` }>>, | ||
Expect<Equal<PublicType<{ __h: number, i: unknown }>, { i: unknown }>> | ||
] |