mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 13:30:40 +00:00
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:
parent
2807dcb758
commit
71adace16e
1 changed files with 7 additions and 4 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue