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

未关闭
#6,735 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
typescript

调研方向

首先检查 collections/deep-merge 下现有的 ExpandRecursively utility,并将其与提议的 NonEmptyArray type guard 进行比较。调查新增 @std/types package scope 是否合适,包括哪些 utility 应归入其中,以及替代的类型表示有何不同。完成的标准是就 package scope 和 API 集达成一致,并明确指定相关 utility。

由索引模型根据 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

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

denoland/std 的其他 Issue

查看 denoland/std 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。