nuxt-route-meta icon indicating copy to clipboard operation
nuxt-route-meta copied to clipboard

Meta is not parsed when page component uses mixins

Open dovca opened this issue 3 years ago • 2 comments

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'}})

dovca avatar May 23 '22 12:05 dovca

@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?

dword-design avatar Jul 25 '22 22:07 dword-design

@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?

dovca avatar Jul 26 '22 09:07 dovca