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

Possible alternative solution to problem 15-intersection #69

Open
seblondono opened this issue Dec 20, 2022 · 1 comment
Open

Possible alternative solution to problem 15-intersection #69

seblondono opened this issue Dec 20, 2022 · 1 comment

Comments

@seblondono
Copy link

I came up with a slightly different solution to problem 15-intersection which follows from problem 14-extends.

interface UserWithPosts extends User {
  posts: Post[]
}

This interface also passes the type check and it creates a slightly different code completion on WebStorm (at least)
Screenshot 2022-12-20 at 23 25 58
Screenshot 2022-12-20 at 23 26 26

Vs the video solution using &
Screenshot 2022-12-20 at 23 34 10
Screenshot 2022-12-20 at 23 34 25

There is no massive difference between the 2 but I thought I'd mention it. I imagine using the & operator with type is like using the extends with interfaces. They do the same as far as I can tell.

Thanks a ton for the great content! :)

@sid3r
Copy link

sid3r commented Feb 22, 2023

interface UserWithPosts extends User {
  posts: Post[]
}

This is even better for my taste, simple and straightforward.

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

No branches or pull requests

2 participants