microsoft / microsoft/TypeScript
Incorrect type resolution with nested constructors
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
🔎 Search Terms
nested constructors type resolution anti-pattern
🕗 Version & Regression Information
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because I only report bugs to be helpful, but I don't have time to dive deeper myself.
⏯ Playground Link
💻 Code
export declare const Base: {
new(): {
kind: 'A'
new(): { kind: 'B' }
}
}
const A = new class extends Base { }
const B = new class extends A { }
B.kind // shows 'A', but should be 'B'
🙁 Actual behavior
If a ctor returns another ctor, it repeats the first level. In the above example, B.kind is 'A', but since we extended and instantiated twice, it should be 'B'.
🙂 Expected behavior
After extending twice, it should reach the inner class, instead of repeating the outer one.
Additional information about the issue
I can only reproduce this bug with this weird experimental anti-pattern - so on its own probably not a priority at all, but types should probably reflect the runtime state as much as possible, even in weird edge cases such as this, and it might indicate a deeper underlying issue.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground の再現例から始め、ネストされた2つの new class extends ... 式の型解決を追跡します。2回の拡張とインスタンス化の後、例が B.kind を 'A' ではなく 'B' と報告すれば、作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100