Microsoft/TypeScript
Voir sur GitHubInconsistencies in assignability rules around top-level-like signatures
Open
#62 712 ouverte le 3 nov. 2025
Cursed?Domain: check: Variance RelationshipsHelp WantedPossible Improvement
Métriques du dépôt
- Stars
- (48 455 stars)
- Métriques de merge PR
- (Merge moyen 6j 17h) (9 PRs mergées en 30 j)
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 https://github.com/microsoft/TypeScript/issues/55667 - the fact examples 2-4 error is the reason why that issue exists