microsoft / microsoft/TypeScript
Add overload to `unshift` to catch calling it with zero elements
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
lib Update Request
I often mistake unshift for shift; calling array.unshift() with zero arguments is almost always a mistake, and I'd like it to tell me that.
interface Array<T> {
/**
* @deprecated You probably meant to use `.shift()`
*/
unshift(): number;
/**
* Inserts new elements at the start of an array, and returns the new length of the array.
* @param items Elements to insert at the start of the array.
*/
unshift(...items: T[]): number
}
Configuration Check
My compilation target is ESNext and my lib is the default.
Missing / Incorrect Definition
Array.prototype.unshift
Sample Code
const myArray = ["abc"];
// This should error / warn, as this is almost definitely a mistake
myArray.unshift()
// This should be ok even though the array might have zero elements
myArray.unshift(...myOtherArray)
Documentation Link
Not fully relevant: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue で特定されている Array.prototype.unshift の標準ライブラリ宣言から始め、近隣のオーバーロードの規約を確認してください。配列メソッドに関する既存の型チェックテストを確認します。引数なしの直接呼び出しがエラーとして報告される一方で、別の配列のスプレッドは引き続き有効であれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100