Skip to content

Instantly share code, notes, and snippets.

@Dionid
Last active June 6, 2023 14:42
Show Gist options
  • Save Dionid/616eb8915d1c2b9bb74a56342cf3dbac to your computer and use it in GitHub Desktop.
Save Dionid/616eb8915d1c2b9bb74a56342cf3dbac to your computer and use it in GitHub Desktop.
// #1
class User {
public id: string
public password: string
public emails: Email[]
public deletedAt: Date | null
}
class Email {
public id: string
public value: string
public isActivated: boolean
public main: boolean
}
class UserService {
registerNewUser(password: string, email: string) {
// ...
}
changeUserEmail(user: User, newEmail: string) {
// ...
}
deleteUser(user: User) {
// ...
}
}
// #2
type User = {
id: string
password: string
emails: Email[]
deletedAt: Date | null
}
type Email = {
id: string
value: string
isActivated: boolean
main: boolean
}
const registerNewUser = (password: string, email: string) => {
// ...
}
const changeUserEmail = (user: User, newEmail: string) => {
// ...
}
const deleteUser = (user: User) => {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment