language-tools
language-tools copied to clipboard
`export default` component after defining it with `<script>` AND `<script setup>`
Today I have tried doing the following:
<script lang="ts">
import { defineComponent } from 'vue';
const Comp = defineComponent({});
export default Comp;
</script>
<script setup lang="ts">
const a = 1;
</script>
Surprisingly, Volar started yelling at this code:
A module cannot have multiple default exports.ts(2528)
App.vue(5, 16): The first export default is here.
However in generated JS there are no multiple default exports:
/* Analyzed bindings: {
"defineComponent": "setup-const",
"Comp": "setup-maybe-ref",
"a": "setup-const"
} */
import { defineComponent as _defineComponent } from 'vue'
import { defineComponent } from 'vue';
const Comp = defineComponent({});
const __default__ = Comp;
const __sfc__ = _defineComponent({
...__default__,
__name: 'App',
setup(__props) {
const a = 1;
return () => {}
}
})
__sfc__.__file = "src/App.vue"
export default __sfc__
Also, this does not work either, with the same error:
<script lang="ts">
import { defineComponent } from 'vue';
export default Object.assign(defineComponent({}), { foo: "bar" });
</script>
<script setup lang="ts">
const a = 1;
</script>
Blocked by https://github.com/vuejs/core/pull/9556 because currently we are unable to extract the original component definition