DEV Community

loading...

Discussion on: Advanced TypeScript Exercises - Answer 1

Collapse
jfet97 profile image
Andrea Simone Costa

I only discovered you, and your series, recently (this morning 🤣) but what a magnificent thing!
It's hard to find such advanced material about TS all around the web. I think I'm going to learn so much!

Now, to answer your question about a simpler GetProperty, what about that?

type GetProperty<T, Prop extends keyof T> = T[Prop]
Enter fullscreen mode Exit fullscreen mode
Collapse
macsikora profile image
Pragmatic Maciej Author

Yes and we really don't need to wrap it in our type level function. We can just write MyType[MyProp] directly. Thanks for the great comment and kind words!

Collapse
jfet97 profile image
Andrea Simone Costa

You're welcome 😃