We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f68e8a commit 6ea3fd5Copy full SHA for 6ea3fd5
1 file changed
tests/test_ts_utility.py
@@ -59,6 +59,12 @@ class TodoTD(TypedDict):
59
]
60
61
62
+# KeyOf[T]
63
+# Constructs a union of the names of every member of T.
64
+type KeyOf[T] = Union[
65
+ *[p.name for p in typing.Iter[typing.Members[T]]]
66
+]
67
+
68
# Exclude<T, U>
69
# Constructs a type by excluding from T all union members assignable to U.
70
type Exclude[T, U] = Union[
@@ -203,3 +209,9 @@ def test_extract():
203
209
)
204
210
205
211
assert eval_typing(Extract[str | int | float, str | int]) == (str | int)
212
213
214
+def test_keyof():
215
+ assert eval_typing(KeyOf[Todo]) == (
216
+ Literal["title"] | Literal["description"] | Literal["completed"]
217
+ )
0 commit comments