<!-- src/runtime/components/MyComponent.vue -->
<script lang="ts">
import { defineComponent, ref } from 'vue';
import type { MyEmit } from '../types';
export default defineComponent({
inheritAttrs: false,
emits: {} as unknown as MyEmit,
});
</script>
<script setup lang="ts">
const text = ref('test');
const foo: MyEmit = {
click: () => {
console.log('11');
},
};
</script>
<template>
<div>{{ text }}</div>
<div>{{ foo }}</div>
</template>
After running nuxt-module-build build the following component is generated in the dist folder. However, only the first script block is converted to JS, and the second is still TS. Types imported from the first block have been moved to MyComponent.vue.d.ts and the second block cannot see those types. Thus it will result in a type error when the end user runs nuxi typecheck with this module installed.
Reproduction
https://stackblitz.com/edit/github-medst6
Describe the bug
After running
nuxt-module-build build
the following component is generated in thedist
folder. However, only the first script block is converted to JS, and the second is still TS. Types imported from the first block have been moved toMyComponent.vue.d.ts
and the second block cannot see those types. Thus it will result in a type error when the end user runsnuxi typecheck
with this module installed.