mirror of
https://github.com/luau-lang/rfcs.git
synced 2025-05-04 10:43:48 +01:00
inital commit
This commit is contained in:
parent
84f9815c32
commit
46850cbfb2
1 changed files with 19 additions and 0 deletions
19
docs/types-library-optional.md
Normal file
19
docs/types-library-optional.md
Normal file
|
@ -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))`.
|
Loading…
Add table
Reference in a new issue