Skip to content

Infering names of fields of inside a table, inside a class #3080

Answered by tomlau10
Mugworth asked this question in Q&A
Discussion options

You must be logged in to vote

IIUC, you want self.animation.types to suggest default / second as its fields?
In other words, you want the return table type of the callback from Animation.build(), to be the type of self.animation.types?

firstly your syntax is incorrect

The syntax @field types.default ... in your original comment is incorrect.
You cannot define nested sub fields in this way.
The closest thing is using table literal:

---@field types { default: Animation.Simple, second: Animation.Simple }

-- or in multi-lined format

---@field types {
--- default: Animation.Simple,
--- second: Animation.Simple,
---}

but of course this still doesn't fulfil your request that automatically suggest default/second fields with…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tomlau10
Comment options

Answer selected by Mugworth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants