Skip to content

Inconsistencies in assignability rules around top-level-like signaturesΒ #62712

@Andarist

Description

@Andarist

πŸ”Ž Search Terms

assignability any never signature

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=6.0.0-dev.20251030#code/PTAEGcHsFcCcGMCmoCG5wEsDmA7FAjAG2QBdJQSALUlWLREgKHkh3BItvpIEYAuUAAoAdKK7gBKHAE8AlKAC8APlQzFQ0cPECciAG6JY85aADkAM0iRTjRiAgoAtsihwkAGlD5oHElwagOJAA7qCUaKAAVBgAJog4JBjwKISRoLAMcDgU0gAOyBFULjAIBTgxqISEoJDmqBDQMXHZGBzmKBiE4Mys7Jx0DABMAiJidBKqcooqFlam6qNa4zr6hsYzlta29piOnbSgGOjQiJ5+Axzh4BTUDs7pmbDZERjZAAbn3DxvQlJT3r5KEcKBh7vhIFQICUkKoKp8AuEDFFos1EslUmlEAAPEiwFCgYgoGKvLCgXK0JwMQyww5tDpdRA9Ni+fwkADMIy4AmgOAA1kFgjhPJptJN1pMFlzQDz+SEhaARctAqsjNMzJsbHYwLt9rBDsdTv1uGFCrdwJSHiQsqhrq9QB9Wd9fjJ5ACbsDEmCIZQoW4ynDWSakZEUfE0SkQ-aqEcfuS8c4SNSpBVWqB2p1wIyWMyjQwACwjaMTGUC+WKrATP7iv7qcw8+CJVhCIvcvml4VjCsrAyqgDelutACJNoOANygAC+o8YQA

πŸ’» Code

// source assignable to the target
const target1: (...args: any) => any = (...args: never) => 'foo'

// same source, but target now has *identical* return type as the source and all of a sudden it fails
const target2: (...args: any) => 'foo' = (...args: never) => 'foo'

// similar issue, target has the same return as in `target1` (any) but this time both source and target have **identical** extra leading parameter and it fails
const target3: (arg: unknown, ...args: any) => any = (arg: unknown, ...args: never) => 'foo'

// similar issue, target has the same return as in `target1` (any) but this time both source and target have **identical** `this` parameter and it fails
const target4: (this: unknown, ...args: any) => any = function (this: unknown, ...args: never) { return "foo"; };

πŸ™ Actual behavior

Assignability rules behave weirdly/inconsistently in those simple examples

πŸ™‚ Expected behavior

I'd expect more consistent results

Additional information about the issue

relates to #55667 - the fact examples 2-4 error is the reason why that issue exists

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