microsoft / microsoft/TypeScript
Allow mapped tuples to have behaviour based on index
まだ誰も着手していません。
- 主要言語
- 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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue ではファイル、テスト、エントリポイントが指定されていないため、まず現在の mapped tuple の挙動と、TypeScript が tuple の位置をどのように表現するかを確認してください。実装とテストを提案する前に、最初と最後のインデックスに基づく optionality の意図されたルールを明確にしてください。完了とするには、合意された設計と、検証済みのコンパイラーの挙動が必要です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100