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

Typing of v-for :key does not accept symbol #4240

Closed
AlexandraCaragata opened this issue Aug 3, 2021 · 1 comment
Closed

Typing of v-for :key does not accept symbol #4240

AlexandraCaragata opened this issue Aug 3, 2021 · 1 comment

Comments

@AlexandraCaragata
Copy link
Contributor

Version

3.2.0-beta.7

Reproduction link

Reproduction link

Steps to reproduce

  1. Use symbols as :key in a v-for.
  2. Compile component incl. template with TypeScript (vue-tsc --noEmit)

What is expected?

Vue allows using a symbol as a v-for :key. This is very useful in some situations, since symbols are an automatically unique primitive. I would expect the typing of v-for :key to include symbol.

What is actually happening?

The code works at runtime, but the type checking step complains that the provided v-for :key is not string | number | undefined.


Symbols have been officially supported as a v-for :key since Vue 2.5. For some reason, the typing (but not the functionality) regressed with Vue 3.0.

We noticed this bug after switching from Vue-cli to Vite, since Vite supports TypeScript in templates out-of-the-box.

@AlexandraCaragata
Copy link
Contributor Author

I will create a PR with a fix for this.

AlexandraCaragata added a commit to AlexandraCaragata/vue-next that referenced this issue Aug 3, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants