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

Meta is not parsed when page component uses mixins #103

Open
dovca opened this issue May 23, 2022 · 2 comments
Open

Meta is not parsed when page component uses mixins #103

dovca opened this issue May 23, 2022 · 2 comments

Comments

@dovca
Copy link

dovca commented May 23, 2022

Hi, I'm using class decorators in SFCs. I found a bug in the parsing algorithm. It only accepts page components which extend Vue directly. The parsing fails to find meta when the component uses mixins:

// pages/index.vue

import {Component, mixins} from 'nuxt-property-decorator';
import SomeMixin from '@/mixins/SomeMixin';

@Component({})
export default PageComponent extends mixins(SomeMixin) {
  meta = {foo: 'bar'};
}

May I suggest parsing the @Component decorator options instead like so?: (only if the typescript AST parser allows it)

@Component({meta: {foo: 'bar'}})
@dword-design
Copy link
Owner

@dovca How is the logic behind it if you add meta to both @Component and component body? Is it merged? Or does one have precedence?

@dovca
Copy link
Author

dovca commented Jul 26, 2022

@dword-design In a decent IDE like WebStorm, you can get some basic type hints when defining meta in the decorator thanks to this, which does not happen when defining it as a property in the class body. Given this slight advantage, I would personally prefer decorator meta having precedence over component body meta. After all, it wouldn't make sense to define it in both places, since none of them have access to the encapsulating component, which would give it an advantage. That means all data in meta is most likely static and any merging can be done by the code author manually. What are your thoughts on this?

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

No branches or pull requests

2 participants