From c6dc391f2ef9a69579da4954cbe142dd76322b23 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Fri, 5 Aug 2022 16:03:04 -0700 Subject: [PATCH] add a bit about the syntax of exact and inexact tables explicitly --- rfcs/exact-table-types.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rfcs/exact-table-types.md b/rfcs/exact-table-types.md index 02928060d..50dc5fe35 100644 --- a/rfcs/exact-table-types.md +++ b/rfcs/exact-table-types.md @@ -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