Intermediate
A Function That Never Returns
findUser should return a User, or stop the program with a clear message. TypeScript complains that user might still be undefined at return user, because it doesn't know fail never comes back.
Give fail the right return type so the compiler understands. The checks also assign fail("x") to a never variable.
What Check tests
- Your code has no type errors
failhas the type never- The console prints
Ravi - The console prints
No user 9
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.