add a bit about the syntax of exact and inexact tables explicitly

This commit is contained in:
Aaron Weiss 2022-08-05 16:03:04 -07:00
parent 8496fcddc5
commit c6dc391f2e

View file

@ -104,6 +104,11 @@ inexact and therefore open to having additional properties, we would include an
type, e.g. `{ x: number, y: number, ...}`. This was originally proposed as an alternative design in
the [width subtyping][width-subtyping] proposal.
We propose these syntaxes (`{field: type}` and `{field: type, ...}`) for exact and inexact tables
respectively because they are fairly lightweight, support anonymous usage, and represent a fairly
mild change from the syntax that we already have. Alternative syntax options like `interface` in
TypeScript would represent a bigger deviation from our current syntax of types.
There are a few apparent benefits to this approach. First, it means that a programmer designing an
API has to make a conscious decision that "yes, in fact, it is sensible to treat all of the unlisted
properties of this parameter as being unrelated to the behavior of this function." The type checker