-
Notifications
You must be signed in to change notification settings - Fork 606
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
how to import type xxxProps / xxxEmits / xxxSlots #3124
Comments
You can use |
I have the same issue when importing by (with v3) |
Can you share the code of the component that causes the error? (.../app/pages/ResDossier/components/MyCustomComponent.vue) |
You can reproduce this issue by create this simple component : <template>
<UInput v-bind="props">
<!-- slots, etc... -->
</UInput>
</template>
<script setup lang="ts">
import type {InputProps, InputSlots} from '@nuxt/ui'; // or '#ui/types'
const props = defineProps<InputProps>();
const slots = defineSlots<InputSlots>();
</script> And using this component in See repro : codesandox |
Right, sorry, I'll re-open and check this out! |
I figured out how to fix this issue : Since you define appConfig in each component's vue file, when accessing types, Typescript try to redefine appConfig (like it is in same scope). Renaming appConfig in each components with a distinct name resolve this. exemple for the Tooltip component, replace : - const appConfig = _appConfig as AppConfig & { ui: { tooltip: Partial<typeof theme> } }
+ const appConfigTooltip = _appConfig as AppConfig & { ui: { tooltip: Partial<typeof theme> } }
-const tooltip = tv({ extend: tv(theme), ...(appConfig.ui?.tooltip || {}) })
+const tooltip = tv({ extend: tv(theme), ...(appConfigTooltip.ui?.tooltip || {}) }) If you're OK with this, I can make a PR ? |
Great find! I'd like to look deeper into this, I don't understand why the |
Description
I need to create custom components including @nuxt/ui components and forward props, emits on this components.
When importing (in vue file)
I receive this error on execution :
Is there another way to import theses types ?
The text was updated successfully, but these errors were encountered: