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

fix(interpolation/v-for): allow optional index parameter for numeric iteration #3222

Merged
merged 1 commit into from
Nov 13, 2021

Conversation

thebanjomatic
Copy link

@thebanjomatic thebanjomatic commented Nov 1, 2021

The v-for directive when iterating over a number provides both the 1-based numeric value, and the 0-based index to the iteration function. Vetur currently shows this as an error when you are using the experimental.templateInterpolationService option and attempt to use the index.

Existing behavior:
image

No overload matches this call.
  The last overload gave the following error.
    Argument of type 'number' is not assignable to parameter of type 'object'.Vetur(2769)

This change adds the missing second parameter to the iteration helper for the num: number overload, and existing usages with a single parameter should continue to work.

The `v-for` directive when value is a number provides both the 1-based numeric value, and the 0-based index to the iteration function, however vetur currently shows this as an error when you are using the experimental.templateInterpolationService option.

This change adds the missing second parameter to the iteration helper for the `num: number` overload, and existing usages with a single parameter should continue to work.
@thebanjomatic thebanjomatic changed the title fix(interpolation/v-for): allow optional index fix(interpolation/v-for): allow optional index parameter for numeric iteration Nov 1, 2021
@thebanjomatic
Copy link
Author

@yoyo930021 sorry to ping you, but I wasn't sure if you've seen this PR yet.

Copy link
Member

@yoyo930021 yoyo930021 left a comment

Choose a reason for hiding this comment

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

LGTM

@yoyo930021 yoyo930021 merged commit b4480cb into vuejs:master Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants