From 46850cbfb2c7f21add85081a76e2e3926fe3611c Mon Sep 17 00:00:00 2001 From: gaymeowing <62822174+gaymeowing@users.noreply.github.com> Date: Fri, 11 Apr 2025 07:58:17 -0400 Subject: [PATCH] inital commit --- docs/types-library-optional.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/types-library-optional.md diff --git a/docs/types-library-optional.md b/docs/types-library-optional.md new file mode 100644 index 0000000..1c685d9 --- /dev/null +++ b/docs/types-library-optional.md @@ -0,0 +1,19 @@ +# types.optional + +## Summary + +This RFC proposes adding a new method to the `types` library in type functions, that provides a shorthand for `types.unionof(type, types.singleton(nil))` + +## Motivation + +Currently its annoying to have to always type `types.unionof(meow, types.singleton(nil))` to make a optional type, this leads to having the following appear in codebases that make use of optional types a lot in type functions: + +```luau +type function optional(type) + return types.unionof(type, types.singleton(nil)) +end +``` + +## Design + +As a solution, a new method to the `types` library should be added called `optional`. This new method will act the same as `types.unionof(type, types.singleton(nil))`.