You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Add an option to require type annotations #3447
I would like a way for lua-language-server to apply a "strict" mode to the functions and tables variables of lua files. e.g. if a function takes at least one parameter or has at least one return <foo> statement, it would error if that function doesn't also have a ---@param / ---@return statement to match it.
Issue
There seems to be some arguments that can make lua-language-server more strict, for example these:
But they seem to activate only on inlined functions or functions that have incomplete documentation. So if a function has no docs at all, it gets skipped.
Suggestion
A new diagnostic that maybe can be a warning but can be escalated to an error. And it basically says
If it is a global variable table, it needs a ---@type
If it is a function
And it has at least one parameter
Each parameter must define ---@param with a name + type
And it has at least one non-bare-return `return
Each parameter must define ---@return with type
If the type annotation is a table
Require that the table is "filled out" with concrete types. e.g. ---@type table -> ---@type table<string, integer>
I vibed a linter specifically for this - https://github.com/ColinKennedy/lua-typer - I'd still like LuaLS to adopt the same ideas so I think the issue is worth keeping open but, for now, typer works to find the empty annotations and then LuaLS is there to enforce correctness. In short, it is a little hacky but it works.
Activity
ColinKennedy commentedon Aug 9, 2026
I vibed a linter specifically for this - https://github.com/ColinKennedy/lua-typer - I'd still like LuaLS to adopt the same ideas so I think the issue is worth keeping open but, for now,
typerworks to find the empty annotations and then LuaLS is there to enforce correctness. In short, it is a little hacky but it works.