General-purpose utility types/type guards (maybe in a new `types` package scope)

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

メンテナーはふだん 1 日以内に返信

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

評価

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

調査の方向性

まず collections/deep-merge にある既存の ExpandRecursively ユーティリティを確認し、提案されている NonEmptyArray 型ガードと比較します。新しい @std/types パッケージスコープが適切かどうかを調査し、どのユーティリティをそこに含めるべきか、また代替となる型表現がどのように異なるかを確認します。パッケージスコープと API セットについて合意し、関連するユーティリティが指定されれば完了です。

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

説明

Is your feature request related to a problem? Please describe.

There are various common utility types that aren't available in TypeScript's built-in libraries. For example:

export type NonEmptyArray<T> = [T, ...T[]]
export function isNonEmptyArray<T>(arr: T[]): arr is NonEmptyArray<T> {
    return arr.length > 0
}

In some cases, these can be somewhat complex, in others (like NonEmptyArray) implementation is somewhat trivial, but also involves design decisions where the tradeoffs may not be initially obvious — for example, what if anything is the practical difference between [T, ...T[]] vs T[] & { 0: T }?

Describe the solution you'd like

Maybe a new @std/types package scope? That would be the first place I'd look for this kind of thing.

The only existing examples I know of in std are ExpandRecursively under collections/deep-merge, but there may be a few more.

Describe alternatives you've considered

Include type utils distributed in various other packages, but that's likely to be less discoverable — I only stumbled upon ExpandRecursively by accident after re-implementing similar logic multiple times.

主要言語
TypeScript
スター
3.6k
フォーク
713
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

denoland/std のほかの issue

denoland/std の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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