mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
add a bit about the syntax of exact and inexact tables explicitly
This commit is contained in:
parent
8496fcddc5
commit
c6dc391f2e
1 changed files with 5 additions and 0 deletions
|
@ -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
|
type, e.g. `{ x: number, y: number, ...}`. This was originally proposed as an alternative design in
|
||||||
the [width subtyping][width-subtyping] proposal.
|
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
|
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
|
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
|
properties of this parameter as being unrelated to the behavior of this function." The type checker
|
||||||
|
|
Loading…
Add table
Reference in a new issue