RFC: Amend 'Default type alias type parameters' for type pack parameters (#238)

* Do not allow regular type assignment to a type pack as a default parameter

* With type pack support in type aliases, this second form with an empty list is now supported

* Update rfcs/syntax-default-type-alias-type-parameters.md

Co-authored-by: Alan Jeffrey <403333+asajeffrey@users.noreply.github.com>

* Update syntax-default-type-alias-type-parameters.md

Even more examples

Co-authored-by: Alan Jeffrey <403333+asajeffrey@users.noreply.github.com>
This commit is contained in:
vegorov-rbx 2021-12-08 04:21:47 -08:00 committed by GitHub
parent 2807dcb758
commit 71adace16e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,9 +48,12 @@ type A<T, U = V, V = T> = ... -- not allowed
Default type parameter values are also allowed for type packs:
```lua
type A<T, U... = ...string> -- ok, variadic type pack
type C<T, U... = string> -- ok, type pack with one element
type D<T..., U... = T...> -- ok
type A<T, U... = ...string> -- ok, variadic type pack
type B<T, U... = ()> -- ok, type pack with no elements
type C<T, U... = (string)> -- ok, type pack with one element
type D<T, U... = (string, number)> -- ok, type pack with two elements
type E<T, U... = (string, ...number)> -- ok, variadic type pack with a different first element
type F<T..., U... = T...> -- ok, same type pack as T...
```
---
@ -68,7 +71,7 @@ If all type parameters have a default type value, it is now possible to referenc
type All<T = string, U = number> = ...
local a: All -- ok
local b: All<> -- not allowed
local b: All<> -- ok as well
```
If type is exported from a module, default type parameter values will still be available when module is imported.