Two relatively minor notes:
Comments are a mixed blessing. What’s much better is self-documenting code, which includes naming conventions. When I see a bare user
, I instantly assume “that’s a lexically-scoped variable”. Having that name potentially collide with a type of the name user
is confusing. So types should always start with a capital letter (PascalCase
).
Secondly, since you already bothered to define a User
type, that’s great. Use it. profile: User
, not profile: any
. any
totally nerfs much of the value in using TypeScript in the first place. You virtually never need it in your own code - it’s generally most needed when writing libraries.