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

Add opportunity to directly assign undefined for optional properties #438

Open
Denllay opened this issue Feb 6, 2024 · 1 comment
Open

Comments

@Denllay
Copy link

Denllay commented Feb 6, 2024

Right now, we cannot assign the undefined property value, even if it is optional. So it forces to write additional boilerplate to return empty object instead of undefined property. For example:

const getProperty = () => {
  if (condition) {
    return { property };
  }

  return {};
}

...

request: {
...getProperty()
...
}

// instead of

request: {
property: condition ? property : undefined
}
@igorkamyshev igorkamyshev added type:enhancement New feature or request scope:core labels Feb 6, 2024
@igorkamyshev igorkamyshev added this to the v1.0 milestone Feb 27, 2024
igorkamyshev added a commit that referenced this issue Mar 7, 2024
@igorkamyshev
Copy link
Owner

I've added some tests (add5a6c) for this use-case, and it's working correct 🤔

Can you elaborate a bit or provide reproduce of broken types?

@igorkamyshev igorkamyshev removed this from the v1.0 milestone Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants