Incorrect docs: type compatibility for functions with overloads

Open Beginner friendly
#30,075 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
documentation

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.

Description

Docs

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".

Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 15h
Merged PRs (30d)
106

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/TypeScript

All issues in microsoft/TypeScript

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.