Skip to content

Instantly share code, notes, and snippets.

@mayognaise
Last active July 27, 2023 06:21
Show Gist options
  • Save mayognaise/54237aef14ba3dbb80d5ce15482a51bd to your computer and use it in GitHub Desktop.
Save mayognaise/54237aef14ba3dbb80d5ce15482a51bd to your computer and use it in GitHub Desktop.
Define keys as null or optional
// Define either undefined or null
type Maybe<T> = T | undefined | null;
type User = {
name: string
email: string
phone: Maybe<string>
}
/**
type User = {
name: string;
email: string;
phone: string | null | undefined;
}
*/
type Question = {
value: string
user: Maybe<User>
}
/**
type Question = {
value: string;
user: User | undefined | null;
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment