-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Exact Table Types #11
base: master
Are you sure you want to change the base?
Conversation
What will be the mechanism for the warnings? |
It might require making the linter more type-aware, which is perhaps more work than I had anticipated it being when I first wrote this. |
This RFC is interesting though, and pursues something I pursued, with setting sealed tables and unsealed tables. |
One more use case for this: iterator of some inexact tables results in function f(t: { p: string })
for i, v in t do -- i : unknown, v : unknown
end
end
f({ p = "a", q = 7 }) -- q : number is reachable to the iterator, so v : string does not hold |
Other use case is to support Module stuff e.g. react-lua If you create a custom extended property, you'll notice that everyone says that if you do use require, all tables become unmutable... though... you see the issue e.g. when you want |
if you do this local test = typeof({}) & typeof({}) it actually creates an Intersection and the ConstraintSolver will skip it hence why the autocomplete never knows. Which seems to be intended. Free Types are an exception but they break somehow. Aslong the tables aren't put into one type, I don't really know if this would work. |
Rendered
Migrated from luau-lang/luau#624.