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

updated typing of key in VNodeProps (fix #4240) #4242

Merged
merged 1 commit into from
Aug 6, 2021

Conversation

AlexandraCaragata
Copy link
Contributor

Issue

#4240

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 was 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 was actually happening?

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

What is the fix doing?

Added type support for symbol for a v-for :key.


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.

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember the reason for symbol not being supported before and I couldn't find any old issue or PR. I would say this is worth adding.

@yyx990803 yyx990803 merged commit d045055 into vuejs:master Aug 6, 2021
@Shinigami92
Copy link
Contributor

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

Successfully merging this pull request may close these issues.

5 participants