I'm new to Typescript so there may be some setup I missed. When using this.$prismic
in components, either in the fetch()
hook (sadly can't use asyncData
on component) or in methods
, I get these errors:
11:30:31ue:37:14
TS2339: Property '$prismic' does not exist on type 'CombinedVueInstance<Vue, unknown, { fullHtml(image: { image: { url: String; alt: String; }; caption: String; }): String; }, unknown, Readonly<{ slice: any; }>>'.
35 | }): String {
36 | return `<img src="${image.image.url}" alt="${image.image.alt}">
> 37 | ${this.$prismic.asHtml(image.caption)}`
| ^^^^^^^^
38 | },
39 | },
40 | })
ERROR in components/Navbar.vue:17:26
TS7016: Could not find a declaration file for module 'vue-fragment'. 'F:/Projects/website-musicandmore/node_modules/vue-fragment/dist/vue-fragment.min.js' implicitly has an 'any' type.
Try `npm install @types/vue-fragment` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-fragment';`
15 | <script lang="ts">
16 | import Vue from 'vue'
> 17 | import { Fragment } from 'vue-fragment'
| ^^^^^^^^^^^^^^
18 |
19 | export default Vue.extend({
20 | components: {
ERROR in components/Navbar.vue:26:36
TS2339: Property '$prismic' does not exist on type 'CombinedVueInstance<Vue, { pages: never[]; }, unknown, unknown, Readonly<Record<never, any>>>'.
24 | async fetch() {
25 | try {
> 26 | let { results } = await this.$prismic.api.query([
| ^^^^^^^^
27 | this.$prismic.predicates.at('document.type', 'pages'),
28 | ])
29 |
ERROR in components/Navbar.vue:27:14
TS2339: Property '$prismic' does not exist on type 'CombinedVueInstance<Vue, { pages: never[]; }, unknown, unknown, Readonly<Record<never, any>>>'.
25 | try {
26 | let { results } = await this.$prismic.api.query([
> 27 | this.$prismic.predicates.at('document.type', 'pages'),
| ^^^^^^^^
28 | ])
29 |
30 | results = results.sort(
i Waiting for file changes 11:30:33
i Memory usage: 683 MB (RSS: 797 MB) 11:30:33
i Listening on: http://localhost:3000/ 11:30:33