Answer the question
In order to leave comments, you need to log in
JsonLd for vue + typescript?
@Template
@Component<PageMeta>(
{
jsonld() {
return {
'@context': 'http://schema.org/',
'@type': 'Organization',
'url': 'https://test.tv',
'logo': 'static/favico/android-chrome-192x192.png',
};
},
] ERROR in /var/www/test/src/components/public/partials/page_meta/PageMeta.ts(18,9)
TS2345: Argument of type '{ jsonld(): { '@context': string; '@type': string; url: string; logo: string; };
metaInfo(): MetaInfo; }' is not assignable to parameter of type 'ComponentOptions<PageMeta, DefaultData<PageMeta>,
DefaultMethods<PageMeta>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>'.
Object literal may only specify known properties, and 'jsonld' does not exist in type 'ComponentOptions<PageMeta,
DefaultData<PageMeta>, DefaultMethods<PageMeta>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>
& ThisType<...>'.
Answer the question
In order to leave comments, you need to log in
If there is no typing for something, you first look in @types/<libname>
and if there is none, you make it yourself.
This is the reality of typescript - you work primarily in a javascript environment.
Add the following interface extension somewhere:
declare module 'vue/types/options' {
interface ComponentOptions<V extends Vue> {
jsonld?: any; // на самом деле не any, а то чего ждёт либа
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question