You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// But because typescript understands that `fail` function returns `never`
45
45
// It can allow you to call it as you might be using it for runtime safety / exhaustive checks.
46
-
fail("Unexhaustive!");
46
+
returnfail("Unexhaustive!");
47
47
}
48
48
49
-
function fail(message:string) { thrownewError(message); }
49
+
function fail(message:string):never { thrownewError(message); }
50
50
```
51
51
52
52
And because `never` is only assignable to another `never` you can use it for *compile time* exhaustive checks as well. This is covered in the [*discriminated union* section](./discriminated-unions.md).
0 commit comments