question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript support

See original GitHub issue

Hello. I just encountered this error when using nuxt with Typescript.

20:2 No overload matches this call. Overload 1 of 2, '(options: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> & ThisType<...>): <VC extends VueClass<...>>(target: VC) => VC', gave the following error. Type '({ $prismic }: { $prismic: any; }) => { posts: any; }' is not assignable to type '(ctx: Context) => void | object | Promise<void | object>'. Types of parameters '__0' and 'ctx' are incompatible. Property '$prismic' is missing in type 'Context' but required in type '{ $prismic: any; }'. Overload 2 of 2, '(target: VueClass<Vue>): VueClass<Vue>', gave the following error. Argument of type '{ asyncData({ $prismic }: { $prismic: any; }): { posts: any; }; components: { ImageBlock: typeof ImageBlock; Paragraph: typeof Paragraph; Card: typeof Card; CallToAction: typeof CallToAction; }; head: { ...; }; }' is not assignable to parameter of type 'VueClass<Vue>'. Object literal may only specify known properties, and 'asyncData' does not exist in type 'VueClass<Vue>'.

My code:

async asyncData ({  $prismic } : {  $prismic : any }) {
		...
}

My solution was to use $prismic like this:

async asyncData () {
		const { $prismic } = Vue.prototype.$nuxt
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
lihbrcommented, Jan 6, 2021

Hey, I guess it was from here: https://github.com/prismicio/prismic-vue/issues/5, really looking forward to move our kit to typescript properly this year ☺️

1reaction
lihbrcommented, Mar 16, 2022

The new version of the module targetting Nuxt 3 comes with first-class TypeScript support 🎉

https://v3.prismic.nuxtjs.org/

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. TypeScript speeds up your development experience by catching errors and providing fixes ...
Read more >
TypeScript - Wikipedia
TypeScript supports definition files that can contain type information of existing JavaScript libraries, much like C++ header files can describe the ...
Read more >
TypeScript Programming with Visual Studio Code
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It offers classes, modules, and interfaces to help you build robust...
Read more >
TypeScript | WebStorm Documentation - JetBrains
WebStorm supports developing, running, and debugging TypeScript source code. ... Learn more from Compiling TypeScript into JavaScript.
Read more >
TypeScript Introduction - W3Schools
TypeScript is JavaScript with added syntax for types. ... as Visual Studio Code, have built-in TypeScript support and can show errors as you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found