We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 235c3a2 commit 7cb073fCopy full SHA for 7cb073f
1 file changed
packages/utils/src/TypeUtils.ts
@@ -1,3 +1,18 @@
1
+/**
2
+ * Util type to create a "subtype" of T. Useful for creating subsets of union
3
+ * types.
4
+ *
5
+ * e.g.
6
+ * declare type Direction = 'north' | 'south' | 'east' | 'west'
7
8
+ * // This works
9
+ * type Down = Extends<Direction, 'south'> // 'south'
10
11
+ * // Compiler will complain
12
+ * type NotDirection = Extends<Direction, 'blah'>
13
+ */
14
+export type Extends<T, U extends T> = U extends T ? U : never;
15
+
16
/**
17
* Util type to extract the value from an object.
18
*
0 commit comments