total-typescript/beginners-typescript-tutorial

Solution 2 for 08 unfinished?

andy1li opened this issue · 1 comments

Thank you, Matt, for your wonderful youtube videos!

Maybe I'm missing something, but it seems that solution no. 2 for exercise 08 does not "ensure that makeUser ALWAYS returns a User"(if the returned object was accidentally modified incorrectly)?

https://github.com/total-typescript/beginners-typescript/blob/f119964ad43dc2e5dfabd08e3aaf8f02c57981e9/src/08-function-return-type-annotations.solution.2.ts#L20-L33

Each problem/solution will be accompanied by a video. This is here for a reason, but it's hard to grok just from reading.

The reason it's here is to demonstrate that you can handle this just via inference - you can meet the user contract just through returning all the proper types.