Skip to content

使用 Partial<T> 类型包裹一个已知类型后,函数字段的参数提示(参数名、类型)丢失,而直接使用原类型则正常 #308

Description

@TAN00XU
---@class TestClass
---@field a fun(self:Player)
---@field b fun(name:string)
local class = {}

---@param opt TestClass
function t1(opt) end

t1({
    a = function(self)-- 提示参数 self: Player
        print("t1")
    end,
    b = function(name)-- 提示参数 name: string
        print("t2")
    end
})

---@param opt Partial<TestClass>
function t2(opt) end

t2({
    a = function(self) -- 无提示,只有 (self)
        print("t2")
    end,
    b = function(name)-- 无提示,只有 (name)
        print("t2")
    end
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions