Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[New Solver] Cannot refine a property on a table with assert after testing typeof(x) == "table" #1803

@JohnnyMorganz

Description

@JohnnyMorganz

Works however if refined using an if condition

--!strict

local x = {} :: unknown

if typeof(x) == "table" then
	-- Works:
	-- if typeof(x.transform) == "function" then
	-- 	local y = x.transform -- y correctly inferred as "function"
	-- end

	assert(typeof(x.transform) == "function") -- Type Error: (11,16) Type 'table' does not have key 'transform'
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnew solverThis issue is specific to the new solver.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions