microsoft / microsoft/TypeScript
Error not issued when global type is an alias of an object type literal
オープン
まだ誰も着手していません。
Bug
Domain: Something Else
Has Repro
Needs Human Review
Needs More Info
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
array, constructor, bracket
🕗 Version & Regression Information
- This is a crash
⏯ Playground Link
💻 Code
// @noLib: true
// @target: esnext
declare global {
const Array: {
<T = unknown>(...args:any[]): Array<T>
new <T = unknown,>(...args:any[]): Array<T>
}
type Array<T> = {
[i: number]: T
length: number
}
}
// all of the below give "Property 'length' is missing in type '{}'...":
; ([1, 2, 3]) satisfies Array<number>;
; ([1, 2, 3]) satisfies { length: number };
declare const ar1: never[]
; ar1 satisfies { length: number };
declare const ar2: number[]
; ar2 satisfies { length: number }
// this should throw an error but it doesn't
// @ts-expect-error
; ([] as number[]) satisfies string[]
export { }
🙁 Actual behavior
Types created with the T[] and objects created with the [x as T] syntax are not typed as Array<T> but instead as {}.
🙂 Expected behavior
I expect either:
T[]syntax andArray<T>to be completely synonymous- A compiler error that the
Arraytype is not an instantiable type
Additional information about the issue
Related to #57009.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript bug-workbench Playground の再現コードから始め、global Array がオブジェクト型リテラルである場合の T[] と Array の挙動を比較します。コンパイラーが global Array エイリアス、配列構文、代入可能性をどのように処理するかを追跡します。完了条件は、両方の形式が同義に振る舞うか、無効な Array 型がコンパイラーエラーを生成し、再現コードの期待値が回帰テストでカバーされることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 52/100