Skip to content

Instantly share code, notes, and snippets.

@dested

dested/fancytypes.ts

Created Apr 17, 2020
Embed
What would you like to do?
export type Discriminate<T, TField extends keyof T, TValue extends T[TField]> = T extends {[field in TField]: TValue}
? T
: never;
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
type IsUnion<T, U extends T = T> = T extends unknown ? ([U] extends [T] ? false : true) : false;
type IsStringUnion<T> = IsUnion<T> extends true ? (T extends string ? true : false) : false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment