microsoft / microsoft/TypeScript
Suggestion: shorthand syntax for annotating function with type
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
I like to define types for my functions by separating the type out from the value:
type id = <A>(a: A) => A;
const id: id = a => a;
This helps particularly for longer functions where the parameter list often spans many columns and multiple lines.
However, compared to Elm/Haskell, this code is quite boilerplate-y. I wonder if there is some shorthand syntax we could add to make this pattern more concise. For example, the same code in Elm/Haskell:
id : a -> a
id a = a
The boilerplate in the current TypeScript syntax is:
- Manual annotation of value (
id) with type of same name (id). Could this be automatic, e.g. matched by name? - TypeScript requires parameter names for the function type, but are these always required? Could the function type simply by
A => A, omitting the parameter names? Or would this cause problems?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提案されている TypeScript の短縮構文を、issue 内の Elm および Haskell の例と比較します。実装箇所とテスト箇所を特定する前に、受け入れられる構文とその型チェック時の動作を定義してください。issue では、ファイル、エントリーポイント、具体的な完了基準が指定されていません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 20/100