Skip to content

Instantly share code, notes, and snippets.

@gabiseabra
Created January 9, 2022 05:53
Show Gist options
  • Select an option

  • Save gabiseabra/e1ff68f7fdaf8da85d5e285eb1d20ffb to your computer and use it in GitHub Desktop.

Select an option

Save gabiseabra/e1ff68f7fdaf8da85d5e285eb1d20ffb to your computer and use it in GitHub Desktop.
// 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