-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add documentation for the never
type
#383
Conversation
# Never | ||
|
||
The `never` type represents the type of values that never occur. | ||
For instance, `never` is the return type for a function that always throws an exception or one that never returns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that true? Do we infer that? Because I'm pretty sure we still infer void
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well.. only for function expressions and lambda's. i should be more specific.
|
||
The `never` type represents the type of values that never occur. | ||
For instance, `never` is the return type for a function that always throws an exception or one that never returns; | ||
`never` is also the type of variables under type guards that are never true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables also acquire the type never
when narrowed by any type guards that can never be true.
For instance, `never` is the return type for a function that always throws an exception or one that never returns; | ||
`never` is also the type of variables under type guards that are never true. | ||
|
||
The `never` type is a subtype of and assignable to every type; however, no type is a subtype of or assignable to `never` (except `never` itself). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This includes the any
type.
# Never | ||
|
||
The `never` type represents the type of values that never occur. | ||
For instance, `never` is the return type for a function expression or a arrow function expresssion that always throws an exception or one that never returns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expresssion -> expression
Fixes #313