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

Property checking of dynamically imported component #3616

Open
frankykubo opened this issue Oct 3, 2023 · 2 comments
Open

Property checking of dynamically imported component #3616

frankykubo opened this issue Oct 3, 2023 · 2 comments

Comments

@frankykubo
Copy link

frankykubo commented Oct 3, 2023

I want to dynamically initialize federated component with defineAsyncComponent method and provide prop typings.

<script setup lang="ts">
    interface Props {
        testProp: string,
    }

    const ComponentTest1: DefineComponent<Props> = defineAsyncComponent(() => import('remote_app/Button'));
    let ComponentTest2: DefineComponent<Props>;
    const Bar = defineAsyncComponent<DefineComponent<Props>>(
        () => import('remote_app/Button') as any,
    );
</script>

<template>
    <ComponentTest1 />
    <ComponentTest2 />
</template>

What happens is quite interesting. Both components register that a prop is missing:
image

When I start writing the attribute, I have intellisense only for the ComponentTest2 component:
image

For ComponentTest1, there is no type-checking happening.
image

Why is that? Is this fixable?

@so1ve
Copy link
Member

so1ve commented Oct 5, 2023

Could you please provide a minimal reproduction?

Sorry, didn't see that codeblock.

@frankykubo
Copy link
Author

Same scenario happens even when I am importing a local .vue component:

const Navbar = defineAsyncComponent(() =>
  import('@/components/includes/Navbar.vue'),
);

Inside Navbar.vue, I have props defined like this (just for an example):

withDefaults(defineProps<{bookOptions?: string[]}>(), {
  bookOptions: undefined,
});

Interesting is that it looks like typescript within script setup can see the props (see image, I got some sort of intellisense):

image

But in template, it remains the same, no intellisense provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants