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

feat(component-meta): expose component type #3286

Merged
merged 1 commit into from Jun 14, 2023
Merged

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Jun 14, 2023

close #3151

Expose type property to meta info:

  • 0: Unknown
  • 1: Component is a class type
  • 2: Component is a function type

cc @chakAs3

@johnsoncodehk johnsoncodehk merged commit ba49f84 into master Jun 14, 2023
6 checks passed
@johnsoncodehk johnsoncodehk deleted the meta-coponent-type branch June 14, 2023 16:40
Comment on lines +253 to +263
function getType() {

const $type = symbolProperties.find(prop => prop.escapedName === 'type');

if ($type) {
const type = typeChecker.getTypeOfSymbolAtLocation($type, symbolNode!);
return Number(typeChecker.typeToString(type));
}

return 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great it was easier than I thought 😄 , so if the return is 0 => it is not a valid Vue component?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's designed that way, I'm just not sure how applicable it is for your use case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very useful, as I'm loading folders with components and *.stories.ts so many are not exposing any vue component

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

Successfully merging this pull request may close these issues.

[Feature request] api that accepts a file ( .vue, .ts, .js, .tsx...) and return if it is a component or no.
2 participants