Extract Types to Extend an External Library
In this exercise, we're importing
fake-external-lib. We'll be working with this fake library throughout this section.
Looking at the definition of
fetchUser, we can see that it doesn't expose a return type from the library. It's just the implementation:
0:00 In this exercise, we're importing fetch user from fake external lib. We're wanting to extend it by adding a full-name property to it. If we command click and actually go to definition, you can see that it doesn't expose a return type from the library itself. It's just basically the implementation. So annoying.
0:22 We want to create a return type of fetch user with full name. We could of course just redeclare it if we want to -- ID, first name, last name. That's just really annoying. What, ideally, we'd do instead is extract the type from the fetch user function. Then pull that in and add full name to it.
0:42 We also need to do the same with parameters of fetch user. If you've done the type transformations module, you'll have seen some of this stuff before. This is just acting as a refresher and, also, introducing the idea of this fake external library that for this section we're going to be interacting with. Good luck.