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

Nuxt generates incorrect types when use pick with transform #22981

Closed
enkot opened this issue Sep 4, 2023 · 4 comments
Closed

Nuxt generates incorrect types when use pick with transform #22981

enkot opened this issue Sep 4, 2023 · 4 comments

Comments

@enkot
Copy link
Contributor

enkot commented Sep 4, 2023

Environment

  • Operating System: Linux
  • Node Version: v16.20.0
  • Nuxt Version: 3.7.0
  • CLI Version: 3.7.3
  • Nitro Version: 2.6.2
  • Package Manager: npm@9.4.2
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-udceba?file=app.vue

Describe the bug

If we change/add another field (bar) in the transform callback and then pick it - Nuxt will show us TS error (nuxi typecheck) but works correctly in runtime:

Type '"bar"' is not assignable to type '"id" | "foo"'.

Expected:

  • correct types when use pick and transform together
  • do not allow to use pick and transform together

Additional context

No response

Logs

No response

@stackblitz
Copy link

stackblitz bot commented Sep 4, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@danielroe
Copy link
Member

I would expect that only pick or transform are used - not both. Perhaps we could document this, or update types to disallow.

@noppytinto
Copy link
Contributor

noppytinto commented Mar 2, 2024

@danielroe I've opened a PR to improve documentation about pick and transform. Hope will be useful!

@noppytinto
Copy link
Contributor

@danielroe opened another PR since I've messed up things in the previous PR 🙄

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

3 participants