-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
defineProps is not defined inside script setup #4994
Comments
You can use https://sfc.vuejs.org/ to reproduce this error. |
Please provide a reproduction as required by the issue guidelines.
This doesn't help because obviously it's not happening to other users. It's related to your build setup and without that information there's nothing we can do. |
Seems like the parser is very strict. This is not well documented (or at all) and I think it should more clear. Those three examples seem like they should work the same. edit: Seems like it is a similar problem to issue #3739 |
const { msg } = toRefs(defineProps({
msg: {
type: String
}
})) |
First I assume my system is properly configured since it all works while using I'm trying to use <script setup lang="coffee">
props = defineProps({a: Number}) # ReferenceError: defineProps is not defined
emit = defineEmits(['b'])
console.log(props)
console.log(emit)
</script> If I remove the <script setup>
const props = defineProps({a: Number})
let emit = defineEmits(['b'])
console.log(props); // works
console.log(emit); // works
</script> Without proper declaration if fails even with plain JS: <script setup>
props = defineProps({a: Number}) // ReferenceError: defineProps is not defined
emit = defineEmits(['b'])
console.log(props);
console.log(emit);
</script> Any chance the code to parse these macros are forcing presence of Any workaround to use coffee script here? |
@xgvargas
However, ESLint gives the warning:
I have tried adding the rule
|
@enjoyyourcopepods you should not do this. defineProps is not accessible at runtime. |
I eventually solved my "defineProps is not defined" ESLint errors by doing the following:
and in the template, e.g. |
Version
3.2.22
Steps to reproduce
Simply have a defineProps inside a script setup. Fails at runtime.
What is expected?
defineProps should be removed by the compiler and not present at runtime
What is actually happening?
defineProps is in the code, but it is not defined
Stack trace:
Uncaught (in promise) ReferenceError: defineProps is not defined
at setup (List.vue.ts?61ab:100)
at callWithErrorHandling (runtime-core.esm-bundler.js?1f4e:6706)
at setupStatefulComponent (runtime-core.esm-bundler.js?1f4e:6315)
at setupComponent (runtime-core.esm-bundler.js?1f4e:6271)
at mountComponent (runtime-core.esm-bundler.js?1f4e:4123)
at processComponent (runtime-core.esm-bundler.js?1f4e:4098)
at patch (runtime-core.esm-bundler.js?1f4e:3693)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?1f4e:4238)
at ReactiveEffect.run (reactivity.esm-bundler.js?a93e:160)
at setupRenderEffect (runtime-core.esm-bundler.js?1f4e:4357)
The text was updated successfully, but these errors were encountered: