Skip to content

Instantly share code, notes, and snippets.

@aiya000
Created February 20, 2021 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aiya000/d5b18b62ba520d4728439c8f89cfb291 to your computer and use it in GitHub Desktop.
Save aiya000/d5b18b62ba520d4728439c8f89cfb291 to your computer and use it in GitHub Desktop.
証明できてる?
/**
* Proves that A and B is the same types.
*/
export type Equal<A, B> = A extends B ? (B extends A ? true : never) : never
/**
* Makes all fields of A to `<its-type> | null`.
*/
export type Nullable<A extends Record<string, unknown>> = { [K in keyof A]: A[K] | null }
const _proofNullable: Equal<Nullable<{ x: string }>, { x: string | null }> = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment