microsoft / microsoft/TypeScript

Function parameter names are incorrectly inferred from variadiac tuples

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

@ahejlsberg がすでに取り組んでいます。

2020年9月9日 から。

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

説明

TypeScript Version: 4.1.0-insiders.20200909

Search Terms:
typescript variadic tuple names curry argument
Code

type Curry<A extends unknown[], R> = A extends [infer Head, ...infer Tail] ? (...args: [Head]) => Curry<Tail, R> : R;
declare const curry: <Args extends unknown[], R>(fn: (...args: Args) => R) => Curry<Args, R>;
declare const f: (x: number, y: string, z: boolean) => string;
const g  = curry(f); // incorrectly inferred as (arg_0: number) => (arg_0: string) => (arg_0: boolean) => string;

Expected behavior:
The inferred type should have the correct argument names from f, like (x: number) => (y: string) => (z: boolean) => string;
Actual behavior:
(arg_0: number) => (arg_0: string) => (arg_0: boolean) => string;
Playground Link:
https://tsplay.dev/nWPZJN

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

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

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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