microsoft / microsoft/TypeScript

Allow mapped tuples to have behaviour based on index

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

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

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Search Terms

mapped tuples index

Suggestion

I want to be able to create a tuple from function parameters and have all elements in the tuple optional other than the firstK

Use Cases

I am trying to create a curry implementation that allows you to curry any number of parameters. The first parameter must be specified but all other params are optional.
Would be good to be able to remove the last param as well.

Examples

something along the lines of

type OptionalExceptFirst<T> = {
    [K in keyof T]:isFirst ? ? T[K] : T[K];
};
type AllExceptLast<T> = {
    [K in keyof T]:isLast ? never : T[K];
};

The syntax will need some work hopefully the intended functionality is clear.

Checklist

My suggestion meets these guidelines:

  • [x ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [ x] This wouldn't change the runtime behavior of existing JavaScript code
  • [ x] This could be implemented without emitting different JS based on the types of the expressions
  • [ x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [ x] This feature would agree with the rest of TypeScript's Design Goals.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

この issue ではファイル、テスト、エントリポイントが指定されていないため、まず現在の mapped tuple の挙動と、TypeScript が tuple の位置をどのように表現するかを確認してください。実装とテストを提案する前に、最初と最後のインデックスに基づく optionality の意図されたルールを明確にしてください。完了とするには、合意された設計と、検証済みのコンパイラーの挙動が必要です。

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

評価

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

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

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