There's a package called ts-expect that we use for this, specifically it's expectNever function. It's pretty neat.
@WesBos
Жыл бұрын
Oh awesome I’ll have to check that out!
@codernerd7076
Жыл бұрын
This is the way! Typescript is here to safe the code from some of Javascript weaknesses 😁
@amixengineer
Жыл бұрын
Thirsty for your TS course. BOSS
@WesBos
Жыл бұрын
Coming in hot
@Zloni
Жыл бұрын
it's VS code extension that gives the error Wes ?
@WesBos
Жыл бұрын
It's called Error Lens. More details here: twitter.com/wesbos/status/1585650063715356673
@Zloni
Жыл бұрын
@@WesBos ok cool, thank you
@yadusolparterre
Жыл бұрын
It's not clear. Why would you ever return a rate as never? And when would you use "never" for?
@stevezelaznik5872
11 ай бұрын
It should be superfluous but apparently it isn’t. Unless you return a type “never” in the default clause or raise an exception, TypeScript will infer the return type of the function wrong. It will add “undefined” as one of the possible return values, coming from the default clause. Typescript should be smarter, but it isn’t, sadly.
@doncooper6354
Жыл бұрын
Finally! someone who STARTS with the use case and then goes on to the mechanics. Thank you! For myself, I almost 'never' need to know HOW, I need to understand WHY!!!! Thank you for your highly unusual but much appreciated clarity. Not sure what makes left-brainers hyper-focus on mechanics, why they cannot see that the hardest part of programming is understanding use cases. The easiest part of programming is understanding how something works. Thank you, thank you, thank you!!!
@amatiasq
Жыл бұрын
`return rate as never` would work too, isn't it?
@atuttle
Жыл бұрын
Super useful!
@andianwar5784
Жыл бұрын
hmm i wonder why this video is not categorized as short instead
@WesBos
Жыл бұрын
It was too long for KZitem so I uploaded as a regular video
Пікірлер: 15