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

function object parameter destructure field without default value will be ignored #59920

Open
tjx666 opened this issue Sep 10, 2024 · 3 comments Β· May be fixed by #59924
Open

function object parameter destructure field without default value will be ignored #59920

tjx666 opened this issue Sep 10, 2024 · 3 comments Β· May be fixed by #59924
Assignees
Labels
Bug A bug in TypeScript

Comments

@tjx666
Copy link

tjx666 commented Sep 10, 2024

πŸ”Ž Search Terms

js, function, parameter, destructure, required

πŸ•— Version & Regression Information

  • This changed between versions 5.6 and latest nightly
  • We use ts 5.5 no this issue, after upgrade this issue occur.

⏯ Playground Link

πŸ’» Code

// utils.js

export const getUserProfileByUsername = ({
  username,
  withEmail = false,
  withNotificationSettings = false,
} = {}) => {
  return {};
};
// main.ts
import { getUserProfileByUsername } from './utils';

getUserProfileByUsername({
  username: 'ly',
});

πŸ™ Actual behavior

src/main.ts:4:3 - error TS2353: Object literal may only specify known properties, and 'username' does not exist in type '{ withEmail?: boolean | undefined; withNotificationSettings?: boolean | undefined; }'.

4   username: 'ly',
    ~~~~~~~~


Found 1 error in src/main.ts:4

πŸ™‚ Expected behavior

no ts validate error

Additional information about the issue

ts 5.x not this issue, must be introduced by 5.6

@SmolPatat
Copy link

https://stackblitz.com/edit/vitejs-vite-usm5mx?file=package.json is not a playground link.
Is there a reason you cannot replicate the issue on https://www.typescriptlang.org/play?

@Andarist
Copy link
Contributor

To be fair, the playground can't be used to demonstrate this because it involves 2 files. There is a bug workbench that can do this though: workbench

@Andarist
Copy link
Contributor

Bisects to #59183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants