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

Type misdeclaration when using <script setup> #4391

Closed
SebastianSpeitel opened this issue Aug 19, 2021 · 0 comments · Fixed by #4406
Closed

Type misdeclaration when using <script setup> #4391

SebastianSpeitel opened this issue Aug 19, 2021 · 0 comments · Fixed by #4406

Comments

@SebastianSpeitel
Copy link

SebastianSpeitel commented Aug 19, 2021

Version

3.2.4

Reproduction link

https://github.com/SebastianSpeitel/vue-bug

Steps to reproduce

npm i
npm run build

What is expected?

Template compiles without errors

What is actually happening?

Build fails with:

semantic error TS2345: Argument of type '{ new (): { $props: VNodeProps; }; __isFragment: true; }' is not assignable to parameter of type 'string'

But ignoring the type-error, the JS output still works.

That's the template:

<template>
  <div>
    <span v-for="s in ['a', 'b']" v-text="s"></span>
  </div>
</template>

<script setup lang="ts">
const message = "Hello Vue!";
</script>

<!-- Works with:   
<script lang="ts">
export default {
  setup() {
    return {};
  }
};
</script>
-->

The diff of the non-setup version and the setup version:

11318,11323d11317
< var script = {
<     setup() {
<         return {};
<     }
< };
< 
11324a11319,11332
> var script = defineComponent({
>     setup(__props) {
>         const message = "Hello Vue!";
>         return (_ctx, _cache) => {
>             return (openBlock(), createElementBlock("div", null, [
>                 (openBlock(), createElementBlock(Fragment, null, renderList(['a', 'b'], (s) => {
>                     return createBaseVNode("span", {
>                         textContent: toDisplayString(s)
>                     }, null, 8 /* PROPS */, _hoisted_1);
>                 }), 64 /* STABLE_FRAGMENT */))
>             ]));
>         };
>     }
> });
11326,11336d11333
< function render(_ctx, _cache, $props, $setup, $data, $options) {
<   return (openBlock(), createElementBlock("div", null, [
<     (openBlock(), createElementBlock(Fragment, null, renderList(['a', 'b'], (s) => {
<       return createBaseVNode("span", {
<         textContent: toDisplayString(s)
<       }, null, 8 /* PROPS */, _hoisted_1)
<     }), 64 /* STABLE_FRAGMENT */))
<   ]))
< }
< 
< script.render = render;

Probably duplicate of #4390

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants