-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Cursed?It's likely this is extremely difficult to fix without making something else much, much worseIt's likely this is extremely difficult to fix without making something else much, much worseDomain: check: Variance RelationshipsThe issue relates to variance relationships between typesThe issue relates to variance relationships between typesHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π 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 #55667 - the fact examples 2-4 error is the reason why that issue exists
LukeAbby and mkantor
Metadata
Metadata
Assignees
Labels
Cursed?It's likely this is extremely difficult to fix without making something else much, much worseIt's likely this is extremely difficult to fix without making something else much, much worseDomain: check: Variance RelationshipsThe issue relates to variance relationships between typesThe issue relates to variance relationships between typesHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases