Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Add documentation for the never type #383

Merged
merged 4 commits into from
Sep 22, 2016
Merged

Add documentation for the never type #383

merged 4 commits into from
Sep 22, 2016

Conversation

mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Sep 15, 2016

Fixes #313

# 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;
Copy link
Member

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.

Copy link
Contributor Author

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.
Copy link
Member

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).
Copy link
Member

@DanielRosenwasser DanielRosenwasser Sep 20, 2016

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.

@mhegazy mhegazy merged commit 452176a into master Sep 22, 2016
@mhegazy mhegazy deleted the neverType branch September 22, 2016 05:13
# 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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expresssion -> expression

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants