microsoft / microsoft/TypeScript
Function parameter names are incorrectly inferred from variadiac tuples
Open
@ahejlsberg is already working on this.
Since Sep 9, 2020.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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
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.