microsoft / microsoft/TypeScript
`pipe` loses generics
オープン
@weswigham がすでに取り組んでいます。
2019年4月9日 から。
Needs Investigation
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.4.1
Search Terms: generic rest parameters pipe compose
Code
I'm defining pipe using generic rest parameters as recommended here: https://github.com/Microsoft/TypeScript/issues/29904#issuecomment-471334674.
// Copied from https://github.com/Microsoft/TypeScript/issues/29904#issuecomment-471334674
declare function pipe<A extends any[], B>(ab: (...args: A) => B): (...args: A) => B;
declare function pipe<A extends any[], B, C>(
ab: (...args: A) => B,
bc: (b: B) => C,
): (...args: A) => C;
declare function pipe<A extends any[], B, C, D>(
ab: (...args: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
): (...args: A) => D;
declare const myGenericFn: <T>(t: T) => string[];
declare const join: (strings: string[]) => string;
// Expected type: `<T>(t: T) => string`
// Actual type: `(t: any) => string`
const fn1 = pipe(
myGenericFn,
join,
);
// Workaround:
// Expected and actual type: `<T>(t: T) => string`
const fn2 = pipe(
myGenericFn,
strings => join(strings),
);
Related Issues: https://github.com/Microsoft/TypeScript/issues/29904
/cc @ahejlsberg
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。