Skip to content

Instantly share code, notes, and snippets.

@tavareshenrique
Created August 9, 2022 23:57
Show Gist options
  • Save tavareshenrique/65abbfdfb1155f98945e2e2c1dcf7a7b to your computer and use it in GitHub Desktop.
Save tavareshenrique/65abbfdfb1155f98945e2e2c1dcf7a7b to your computer and use it in GitHub Desktop.
interface User {
email: string;
password: string;
avatar_url?: string;
}
// Partial<Type>
type PartialUser = Partial<User>;
/**
type PartialUser = {
email?: string | undefined;
password?: string | undefined;
avatar_url?: string | undefined;
}
*/
// Required<Type>
type RequiredUser = Required<User>;
/**
type RequiredUser = {
email: string;
password: string;
avatar_url: string;
}
*/
// Pick<Type, Keys>
type PickUser = Pick<User, "email" | "password">;
/**
* type PickUser = {
* email: string;
* password: string;
* }
* */
// Omit<Type, Keys>
type OmitUser = Omit<User, "email" | "password">;
/**
* type OmitUser = {
* avatar_url: string;
* }
* */
// Record
type LabelType = {
label: string;
color: string;
}
type UserRecord = Record<number, LabelType>;
/**
* type UserRecord = {
* 1: {
* label: string;
* color: string;
* }
* }
* */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment