Last active
July 27, 2023 06:21
-
-
Save mayognaise/54237aef14ba3dbb80d5ce15482a51bd to your computer and use it in GitHub Desktop.
Define keys as null or optional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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