Microsoft/TypeScript
GitHub ã§èŠãInconsistencies in assignability rules around top-level-like signatures
Open
#62,712 opened on 2025幎11æ3æ¥
Cursed?Domain: check: Variance RelationshipsHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
assignability any never signature
ð Version & Regression Information
- This is the behavior in every version I tried
⯠Playground Link
ð» 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 https://github.com/microsoft/TypeScript/issues/55667 - the fact examples 2-4 error is the reason why that issue exists