Skip to content
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

Parameters type loses names with object params #48185

Closed
aphex opened this issue Mar 9, 2022 · 2 comments
Closed

Parameters type loses names with object params #48185

aphex opened this issue Mar 9, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@aphex
Copy link

aphex commented Mar 9, 2022

Bug Report

πŸ”Ž Search Terms

Paramaters, object, named parameters

πŸ•— Version & Regression Information

4.6.2, though likely nor introduced here

⏯ Playground Link

https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABMOcDqcBOBrGYDmAFAB4BciYIAtgEYCmmANIgJ7mW0MCUiA3gLAAoIQF8hoSLATJUJdtXpNW8zkt6IAXohHl1GgPzkAzlEx582xAF4+IngOGCxjgPQvCABwCGmL1TpQ3Ihe5ADaZBQKDMxskaoAuuLg0PBIND4YOOaEAHR5IYgACj5+AQxGADxQLB50cMAy6Fi4BAB89s5CboieJf6BmDwFoRyKzKPRPQ7diLMGxqbmiAA+iOAAJnTAeHTrANxdLparG1s761z6iYISKdLpmLn55MW+-eVVNXUNKHDttkA

πŸ’» Code

function fooWorking(x: number, y: number) { }
function foo(x: number, y: number, { z }: { z?: string } = {}) { }

//(parameter) a: [x: number, y: number]
function barWorking(...a: Parameters<typeof fooWorking>) {}

// (parameter) a: [number, number, ({
//    z?: string | undefined;
// } | undefined)?]
function bar(...a: Parameters<typeof foo>) {}

πŸ™ Actual behavior

bar function is not able to resolve x and y parameter names. This causes the bar function to be type

(a_0: number, a_1: number)

πŸ™‚ Expected behavior

bar function should be able to resolve the x and y parameter names.

@fatcerberus
Copy link

Seems similar to #48049, note this comment:

The short answer is that the parameter -> tuple name feature is "best effort" (since nothing in the type system works/doesn't work depending on these names), and the effort to handle this particular case simply hasn't been done yet

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 10, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' 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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants