Skip to content

cannot convert '{ }' into '{ a: number? }' bug #2164

@jackdotink

Description

@jackdotink
export type function tblpartial(tbl: type)
	assert(tbl:is("table"), "tblpartial can only be applied to tables")
	local new = types.newtable()

	for k, v in tbl:properties() do
		local read = assert(v.read, "properties cannot be write-only")
		new:setreadproperty(k, types.optional(read))
	end

	return new
end

local function tblmerge<T>(base: T, override: tblpartial<T>): T error("unimplemented") end
tblmerge({ a = 1 }, {}) -- Type '{  }' could not be converted into '{ read a: number? }'

This code causes the type error commented on the last line. Expected behavior would be that there are no type errors here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions