From 573b88d3ef86167e2336ad1f67d0265d4f2beede Mon Sep 17 00:00:00 2001 From: "ajeffrey@roblox.com" Date: Thu, 6 Jan 2022 16:52:16 -0600 Subject: [PATCH] Added an example from DataBrain --- rfcs/recursive-type-unrestriction.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rfcs/recursive-type-unrestriction.md b/rfcs/recursive-type-unrestriction.md index 82802e60..145ebef8 100644 --- a/rfcs/recursive-type-unrestriction.md +++ b/rfcs/recursive-type-unrestriction.md @@ -20,7 +20,26 @@ but *not* recursive type functions, such as: type TreeWithMap = { ..., map: (a -> b) -> Tree } ``` -These examples come up naturally in OO code bases with generic types. +These examples come up naturally in OO code bases with generic types, for example +```lua +--!strict +export type PromiseFor = { + andThen: ( + self: PromiseFor, + onFulfilled: ((result: T) -> U)?, + onRejected: ((err: string) -> U)? + ) -> PromiseFor, + catch: ( + self: PromiseFor, + onRejected: ((err: string) -> U)? + ) -> PromiseFor, + finally: ( + self: PromiseFor, + onResolvedOrRejected: ((wasFulfilled: boolean, resultOrErr: T | string) -> U) + ) -> PromiseFor, +} +``` +as discussed at the [Roblox DevForum](https://devforum.roblox.com/t/regression-with-genericrecursively-defined-types/1616647). ## Design