-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Problems with the table annotation.. #1655
Comments
Can't you use |
This notation works fine although there are some inconveniences that come with it.
|
Hello! 👋 Have you tried documenting with It would work like this: ---@class directory
---@field root string
---@type directory
local directories = {
root = "root",
}
print(directories.root) Is there anything I can improve with the documentation that was unclear? |
@frostedpenguin has your issue been resolved? |
Yes I think it makes sense.. maybe there should be a note in the docs that the table annotation can only have primary types as its keys.. |
Should be fixed now. |
Yes, it appears that, at least in --- @type table<"root", string>
local directories = {
root = "root",
}
print(directories["root"]) However, the following is also permitted, should you not want to use --- @type {root: string}
local directories = {
root = "root",
}
print(directories.root) There are often many ways to document things, and you can pick your favourite for your use case 🙂. |
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Linux
What is the issue affecting?
Annotations, Type Checking
Expected Behaviour
I am trying to use the
table
annotation with a customstring type
to better define the key values of my dictionary..This is what I have tried
Actual Behaviour
This also does not work
Reproduction steps
run the code snippets ⌨️
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: