upvote
The thing you gotta make sure to do is basically return inside of switch statements. Typescript will gladly propagate a type that you think is never but is actually ThatOneCaseYouForgot if it's not ever used or referred to.

Every TS project I've worked on has an assertNever(val) thing specifically to check for this kinda stuff

reply
last time I researched enums in TS for a project, they were a mess such that it was better not to use enums in the first place
reply
You can actually have it built-in (via default case in 'switch' statements having a 'never()' statement). But it's less powerful than Rust's.
reply
Or you don't use the defualt case and rely on definite assignment analysis or checks for returns in every code path.

I find the never type in TS actually being a proper bottom type + having control-flow based types vastly superior to what rust offers.

reply