microsoft / microsoft/TypeScript

Inconsistencies in assignability rules around top-level-like signatures

オープン
#62,712 コメント 2 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Cursed? Domain: check: Variance Relationships Help Wanted Possible Improvement
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

🔎 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 https://github.com/microsoft/TypeScript/issues/55667 - the fact examples 2-4 error is the reason why that issue exists

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた TypeScript Playground で 4 つの代入を再現し、関連する issue #55667 を含めて、それらの代入可能性の結果を比較してください。ソースファイルもテストも指定されておらず、期待される一貫したルールも明記されていません。先にどの結果が正しいかを判断してから、checker のエントリポイントを特定し、焦点を絞ったカバレッジを追加する必要があります。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。