microsoft / microsoft/TypeScript
Callback arguments are inferred as any when function has multiple overloads and callback arguments are typed as tuple
Open
Nobody has claimed this yet.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 4.0.5 or higher
Search Terms: function overloads, tuples
Code
function f(callback: (...args: [number, string]) => void): void;
function f(callback: (...args: [number, string, boolean]) => void): void;
function f(callback: (...args: any[]) => void): void {}
// demo
f((num, str) => {}); // first signature: ok
f((num, str, bool) => {}); // second signature: all arguments have any type
Expected behavior: num, str and bool should be type of number, string and boolean.
Actual behavior: num, str and bool are type of any
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.
Research direction
Reproduce the overload and tuple callback example in the linked TypeScript Playground using the reported version. Trace the compiler's overload resolution and callback-parameter inference, then verify that the three parameters receive number, string, and boolean types rather than any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100