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(compiler-sfc): defineProps() should work with multiple declarations #3740

Closed
wants to merge 2 commits into from
Closed

Conversation

HcySunYang
Copy link
Member

Fix: #3739

@HcySunYang HcySunYang added the 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. label May 7, 2021
@Sociosarbis
Copy link

Sociosarbis commented May 7, 2021

I found another bug on current VariableDeclaration string removal implementation.

If user has defineEmit after defineProps or vice versa and the number of declarations is 2 like the following code.

const props = defineProps({
  foo: String
}),
 myEmit = defineEmit(['bar'])

The above code would be compiled to

const props = __props
const 

return { props, myEmit }

which isn't valid too.

@HcySunYang
Copy link
Member Author

I found another bug on current VariableDeclaration string removal implementation.

@Sociosarbis Now this PR can fix that.

@yyx990803
Copy link
Member

See a slightly more efficient fix in 62c1b2f (avoids filter and indexOf calls)

@yyx990803 yyx990803 closed this Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: sfc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using defineProps in a multiple-variable declaration causes compiler to produce invalid code.
4 participants