From 9686135d8e747e9a455049cc250a4388e7dac560 Mon Sep 17 00:00:00 2001 From: "ajeffrey@roblox.com" Date: Mon, 20 Sep 2021 15:45:02 -0500 Subject: [PATCH] Add remark that intersection types can mimic having getters/setters at different types --- rfcs/property-getter-setter.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rfcs/property-getter-setter.md b/rfcs/property-getter-setter.md index d5751f11..676bb897 100644 --- a/rfcs/property-getter-setter.md +++ b/rfcs/property-getter-setter.md @@ -116,6 +116,12 @@ the initial DM. This is unsound, but would support reparenting, and any solution for reparenting is either going to require whole-program analysis or have unsoundness. +### Separate getter and setters via intersection types + +We could restrict the language to only allow a getter or a setter (but +not both) but this is not a restriction due to intersection types, +since we can mimic `{ get p: T, set p: U }` as `{ get p: T } & { set p: U }`. + ### Why separate the getter from the setter? Separate getters and setters were introduced to TypeScript in response