Skip to content

Instantly share code, notes, and snippets.

/* eslint-disable guard-for-in, @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment */
// The nullToUndefined solution is based on these two solutions:
//
// https://stackoverflow.com/a/72549576/10580490
// https://gist.github.com/tkrotoff/a6baf96eb6b61b445a9142e5555511a0
//
// While undefinedToNull is just the reverse of it.
export type NullToUndefined<T> = T extends null | undefined