Skip to content

TypeGuards no longer seem to work #1018

@NyakoFox

Description

@NyakoFox
---@class MyClass
---@class MyInheritedClass : MyClass
---@field test fun(): void


---@return TypeGuard<MyInheritedClass>
function typeguard(instance)
    return true
end

---@type MyClass
local instance = {}

if typeguard(instance) then
    instance:test() -- this is MyClass still, this is a warning! Undefined field `test`.

    ---@cast instance MyInheritedClass
    instance:test()
end

Tested on the latest update, and also #1017, both have this issue

Metadata

Metadata

Assignees

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