microsoft / microsoft/TypeScript

Merge same function signatures for intersection types

Open
#31,930 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 3.6.0-dev.20190611

Search Terms: function signature merge

Code

interface X { 
    name: string;
    method(): void;
}

interface Y { 
    index: number;
    method(): void;
}

var z: X & Y;

z.method(); // <--- Put your cursor here

Expected behavior: IntelliSense should ideally show only one signature.

Actual behavior: It shows two exactly same signatures. Not harming, but weird.

Playground Link: https://www.typescriptlang.org/play/#src=interface%20X%20%7B%20%0D%0A%20%20%20%20name%3A%20string%3B%0D%0A%20%20%20%20method()%3A%20void%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20Y%20%7B%20%0D%0A%20%20%20%20index%3A%20number%3B%0D%0A%20%20%20%20method()%3A%20void%3B%0D%0A%7D%0D%0A%0D%0Avar%20z%3A%20X%20%26%20Y%3B%0D%0A%0D%0Az.method()

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.

Research direction

Start with the provided TypeScript Playground reproduction and investigate the IntelliSense handling for identical method signatures produced by intersection types. Done means the completion or signature display for z.method() shows one signature instead of two while preserving distinct overloads.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.