microsoft / microsoft/TypeScript
Incorrect docs: type compatibility for functions with overloads
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms: functions with overloads, type compatibility
In the docs, it says: "When a function has overloads, each overload in the source type must be matched by a compatible signature on the target type." But it should be "When a function has overloads, each overload in the source type target type must be matched by a compatible signature on the target type source type."
Code
The actual behaviour is right:
type t1 = {
(foo: string): string
(foo: number): number
}
type t2 = {
(foo: string): string
}
declare let v1: t1;
declare let v2: t2;
v2 = v1 // OK
v1 = v2 // Error
The type on the right side of = is considered "the source type".
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
Start at the linked TypeScript Handbook page on type compatibility and locate the section describing overload compatibility. Compare the wording with the provided assignment example, then update the source documentation so the source and target types are described consistently. Verify the rendered page and the example's stated behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100