lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

doc param support generic pattern

Open fesily opened this issue 1 year ago • 3 comments

---@class namespace.A
---@overload fun(x: {id: string})

---@generic T
---@param t namespace.`T`
---@return T
local function new(t) end
new 'A'{
    id
}

fesily avatar Jan 17 '24 07:01 fesily

感觉这个写法怪怪的,可能用形如 `namespace.<T>` 更好。 `T` 则作为 `<T>` 的语法糖。

sumneko avatar Jan 17 '24 09:01 sumneko

可以啊,我也没决定怎么写比较好。

fesily avatar Jan 17 '24 09:01 fesily

不急,过2天看看有没有其他想法

sumneko avatar Jan 17 '24 09:01 sumneko

感觉这个写法怪怪的,可能用形如 `namespace.<T>` 更好。 `T` 则作为 `<T>` 的语法糖。

In my opinion, the current way feels more intuitive. With the current capture being `T` it seems clearer that namespace.`T` is the same as just capturing the original generic class name with some static prefix. Also I just really want to see this get merged lol.

morgverd avatar Mar 18 '24 03:03 morgverd

参考了一下TS,确实最初的写法更好

sumneko avatar Mar 18 '24 03:03 sumneko