Skip to content

Instantly share code, notes, and snippets.

@achmedzhanov
Created March 12, 2019 14:57
Show Gist options
  • Save achmedzhanov/bfa46e2400b70ac2d9182a3859c58de2 to your computer and use it in GitHub Desktop.
Save achmedzhanov/bfa46e2400b70ac2d9182a3859c58de2 to your computer and use it in GitHub Desktop.
TypeScript equeal types
type Eq<T1, T2> = Diff<T1, T2> extends never ? Diff<T2, T1> extends never ? 'equals' : 'neq' : 'neq;
type et1 = Eq<string, number>;
type et2 = Eq<string, string>;
type et3 = Eq<string, string | number>;
type et4 = Eq<string | number, string>;
type et5 = Eq<null, null>;
type et6 = Eq<string | null, null>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment