Created
January 9, 2022 05:53
-
-
Save gabiseabra/e1ff68f7fdaf8da85d5e285eb1d20ffb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // https://github.com/microsoft/TypeScript/issues/13298#issuecomment-885980381 | |
| type UnionToIntersection<U> = ( | |
| U extends never ? never : (arg: U) => never | |
| ) extends (arg: infer I) => void | |
| ? I | |
| : never; | |
| type UnionToTuple<T> = UnionToIntersection< | |
| T extends never ? never : (t: T) => T | |
| > extends (_: never) => infer W | |
| ? [...UnionToTuple<Exclude<T, W>>, W] | |
| : []; | |
| const EQ = null | |
| type Equals<A, B> | |
| = A extends B | |
| ? B extends A | |
| ? typeof EQ : never : never | |
| type StrictEquals<A, B> = Equals<UnionToTuple<A>, UnionToTuple<B>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment