We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Lua's variables can act as C#-like properties by setting __newindex appropriately.
__newindex
Getters and setters occasionally have different type signatures. However, the @field annotation can only represent one type.
@field
-- hoge.meta.lua ---@meta ---@class Point ---@field x number ---@field y number Point = {} ---@class Hoge ---@field position Point ⚠️ actually a property Hoge = {} ---@return Hoge function new_hoge() end
-- main.lua local hoge = new_hoge() hoge.position = { 3, 7 } -- emits "Missing required fields in type `Point`: `x`, `y`" print(hoge.position.x) -- 3.0 print(hoge.position.y) -- 7.0
(Full sample program is here)
It should be annotated as "position's setter receives a table<number, number>, and its getter returns a Point."
position
table<number, number>
Point
How about adding a new syntax to describe this?
The text was updated successfully, but these errors were encountered:
This seems like a duplicated feature request as #1298, which requesting support for setting / getting the same field with different types.
Sorry, something went wrong.
No branches or pull requests
Lua's variables can act as C#-like properties by setting
__newindex
appropriately.Getters and setters occasionally have different type signatures. However, the
@field
annotation can only represent one type.(Full sample program is here)
It should be annotated as "
position
's setter receives atable<number, number>
, and its getter returns aPoint
."How about adding a new syntax to describe this?
The text was updated successfully, but these errors were encountered: