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