EmmyLua / IntelliJ-EmmyLua

Lua IDE/Debugger Plugin for IntelliJ IDEA
https://emmylua.github.io
Apache License 2.0
1.73k stars 290 forks source link

[FR] Optional variable args type #440

Open Kein opened 2 years ago

Kein commented 2 years ago

I've skipped the template because I dont use IntelliJ but since this is the main repo for EmmyLua, as I understand it, any feature requests should go here since rest of the forks and ports will pick it up from upstream.

Description

Right now EL offers typehint @varags that only allows you to specify one type for it and mostly intended to be used in tandem with return values. I have a C binding that accepts optional arguments in a form like (string, string = default, bool = default) and there is no way for me to use a typehint that allows to specify multiple bool | string for kwargs

My proposal is to add @optional that looks for ... in the associative index and allows you to define a multiple input types a-la ---@param ... optional string,bool,number

CppCXY commented 2 years ago

the vscode plugin lua-language-server support ---@param fff? number Other requirements can also be mentioned to the author。

Kein commented 2 years ago

@CppCXY

---@param fff? number

Where is the documentation for that?

Also: image Does not work, it ignores fff?

mikatuo commented 1 year ago

I had the same issue. Then reading the annotation docs found the @overload which worked great for me.

image