Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daniel user api #41

Draft
wants to merge 52 commits into
base: master
Choose a base branch
from
Draft

Daniel user api #41

wants to merge 52 commits into from

Conversation

DuHerb
Copy link

@DuHerb DuHerb commented Jun 14, 2022

DO NOT MERGE
For review only.

dlinds added 30 commits June 6, 2022 17:09
name: string
favoriteColor: string
age: number
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all properties here should be readonly

export class UserAPI {

constructor(private _users: Record<string, IUser> = {}) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an exported Users type would be beneficial here, since it is a domain shape that is used in many places. export type Users = Record<string, IUser>

}

getUserById(id: string): Readonly<IUser> {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getUserById(id: string): Readonly<IUser> {
getUserById(id: string): IUser {

because IUser is readonly (or will be once all of its properties are readonly), we don't need Readonly here.

there is a pattern you might see in some places where a declared interface extends an empty Readonly object, so that the properties don't have to be individually declared as readonly. That pattern would also be acceptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants