-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What lua version(s) is this feature from?
Luau
What feature are you requesting?
Luau has user-defined type functions.
type function rawget(tbl, key)
if not tbl:is("table") then
error("first parameter must be a table type!")
end
for k, v in tbl:properties() do
if k == key then
if v.read ~= v.write then
error("mismatched read/write types found for the property")
end
return v.read
end
end
error("key not found!")
end
type Person = {
name: string,
age: number
}
type ty = rawget<Person, "name"> -- resolves to `ty` defined as `string`Can you go in further detail of what this feature is about?
No response
Please ensure you have done the following actions:
- I have checked that there are no similar requests already open.
- I have confirmed that this has not been implemented on the latest nightly version.
- I have confirmed that this is a custom syntax that requires modifications to be supported.
- I acknowledge my issue will be closed if any step has been skipped.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request