microsoft / microsoft/TypeScript
`pipe` loses generics
Open
@weswigham is already working on this.
Since Apr 9, 2019.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.