Skip to content

IntelliSense should suggest all possible object properties for overloaded function #47498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leoriviera opened this issue Jan 19, 2022 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@leoriviera
Copy link

Bug Report

🔎 Search Terms

union of types on function overload
function overloading not showing arguments in object with intellisense

🕗 Version & Regression Information

  • This is the behavior in every version I tried, including 4.5.4 and the nightly, and I reviewed the FAQ for entries about function overloading.

⏯ Playground Link

Playground link with relevant code

💻 Code

type X = {
    a: number;
};

type Y = { 
    a: number;
    b: string;
};

function f(args: X): void;
function f(args: Y): void;

function f(args: X | Y){}

f({
    a: 7,
    |
})

Trigger completions at |

🙁 Actual behavior

No further completion suggestions are returned.

🙂 Expected behavior

A suggestion for both b should be returned as that is a valid option if args is of type Y.

@MartinJohns
Copy link
Contributor

Related, or perhaps even a duplicate: #47227

You don't get any further completions because you already have a valid object.

@leoriviera
Copy link
Author

Related, or perhaps even a duplicate: #47227

You don't get any further completions because you already have a valid object.

I did think that would be the case, but it does feel like a bit of an odd behaviour to have as you could have another valid object with the b as a property.

@leoriviera leoriviera changed the title IntelliSense should suggest all possible object attributes for overloaded function IntelliSense should suggest all possible object properties for overloaded function Jan 19, 2022
@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Jan 19, 2022
@RyanCavanaugh
Copy link
Member

This is the intended behavior (as in, it used to work this way and now it doesn't) - people didn't like when "extra" properties showed up in the list, especially in cases where there was an obvious discriminant argument earlier in the argument list.

@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants