Skip to content

Using type function in return type annotation position causing unrelated type errors #2264

@PhoenixWhitefire

Description

@PhoenixWhitefire

Given;

type Things = {
	Foo: boolean,
    Bar: number
}

type function Thingtersector(ty: type)
	assert(ty:is("singleton") or ty:is("union"))

    if ty:is("union") then
        for _, v in ty:components() do
            assert(v:is("singleton"))
        end
    end

    return types.never
end

local function create<T>(_: { T | keyof<Things> }): Thingtersector<T>
	return nil :: any
end

local _hello = create({ "Foo" })

, the Type Error;

Image

, is generated. I don't know what it's supposed to mean, but removing the use of UDTF and instead annotating the return value as just unknown or some other type removes the Type Error.

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