Skip to content

[vue-component-meta] Type should include namespaces #5323

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

Closed
OndrejHj04 opened this issue Apr 18, 2025 · 2 comments · Fixed by #5326
Closed

[vue-component-meta] Type should include namespaces #5323

OndrejHj04 opened this issue Apr 18, 2025 · 2 comments · Fixed by #5326

Comments

@OndrejHj04
Copy link

What problem does this feature solve?

When using vue-component-meta to analyze component props that utilize namespaced types the library drops the namespace and returns only the base type name.

When I define component props like this:

import { Namespace } from './types';

const props = defineProps<{
  testProp: Namespace.Data;
}>();

I would expect the getComponentMeta('').props to return a type Namespace.Data for this particular property, however the returned type is only Data (all the namespaces are dropped).

What does the proposed solution look like?

I found out that this behaviour can be fixed by changing the type generation function from typeChecker.typeToString(subtype) to typeChecker.typeToString(subtype, undefined, ts.TypeFormatFlags.UseFullyQualifiedType).

I am not sure if dropping the namespaces is a feature of the library, but I definitely dont find this behaviour helpful. I would be glad if I can turn this setting on in MetaCheckerOptions.

@OndrejHj04
Copy link
Author

Hey @KazariEX, thank you for your changes.

Besides this issue, I also encounter a problem with type truncation. When a props is defined as a large union the type is truncated to ... XX more ..., which is not a valid type. I found out that using ts.TypeFormatFlags.NoTruncation solve this particular problem.

@KazariEX
Copy link
Member

Nice find!

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