The type 'VueClass<Vue>' cannot be assigned to the Apollo parameter

I am currently in the process of developing a 'Nuxt.js' application using typescript.

Below is the code snippet I am working with:

<script lang='ts'>
    import {Component, Vue} from 'nuxt-property-decorator';
    import {LOCATION} from '~/constants/graphql/location';

    @Component({
        apollo: {
            getLocation: {
                query: LOCATION,
                variables(): object {
                    return {
                        id: 10,
                    };
                },
                prefetch: true,
            },
        },
    })
    export default class Home extends Vue {
    }
</script>

The issue I am encountering is as follows:

Argument of type '{ apollo: { getLocation: { query: any; variables(): object; prefetch: boolean; }; }; }' is not assignable to parameter of type 'VueClass<Vue>'.

Object literal may only specify known properties, and 'apollo' does not exist in type 'VueClass<Vue>'.

I understand this error originates from TypeScript, but how can I resolve it?

Answer №1

The configuration options for the "apollo" that you mentioned appear to be correct, assuming you plan to utilize the "vue-apollo" package in conjunction with Apollo functionalities.

If you're encountering this error message, it could indicate that the "vue-apollo" package has not been properly installed or there may be an issue during the installation process.

Take a look at the Vue Chrome debugger tool within your webpage - do all components have the "$apollo" property present? If not, the root cause could be due to incomplete installation of the "vue-apollo" plugin.

Answer №2

In the VueClass Type, @Component can take a parameter where the elements are props, components, methods, etc. as shown in this example:

@Component({

  components: {

    HelloWorld

}})

Answer №3

Make sure to modify your tsconfig.json by adding the following:

"strictFunctionTypes": false

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for stopping special characters from being copied and pasted into a number field

My goal is to ensure that only numbers can be copied and pasted into the 'number field'. By preventing the copy and paste of characters like 'e', '+', '-', and '.', I can ensure that the number field only c ...

error: encountering issue with Vue TypeScript Jest tests - '$store' property is undefined

I've been facing issues with my tests failing after a recent npm install. I've tried adjusting versions up and down, but haven't had any success. Interestingly, the $store isn't directly used in any of the components or tests. Despit ...

"An error has occurred stating that the function Factory.function() in AngularJS

I'm a beginner with AngularJS and could use some assistance! My issue involves retrieving JSON data from a URL in a factory function and returning it to the controller. However, I keep getting an error stating that the function doesn't exist. Wh ...

Store the ID of a div in a variable

Currently, I have transformed rock paper scissors from a terminal/console game using prompts and alerts to something playable in a web browser through the use of the jQuery library. In order to achieve this transition, I created images for each hand - roc ...

Incorporating the outcomes obtained from an endless scrolling request into the default results showcased in AngularJS

In my code, I have a function that makes an initial $http call and displays the results. Following this function, there is another function that will make additional calls when the scroll event is triggered (using the ng-Infinite-Scroll module). The issue ...

JavaScript closing of a window

I've been dealing with this issue for the past few hours. Currently, I am utilizing the iframe version of LightFace modal windows: http://davidwalsh.name/facebook-lightbox The problem I'm encountering is the inability to close the modal from w ...

Using a combination of functions to ensure synchronicity in JavaScript operations

Here is the function I have created: $scope.saveManualResendDraft = function(todo) { if ($scope.editMode) { updateStartJobManual(); byeSendManualInputDirectly(); } else { console.log('bye'); } }; I have defin ...

Tips for updating the background color of a specific row

I have a piece of code that I am trying to modify with a specific condition. If {row.BB} is less than or equal to 100, I want to change the background color of the row with this value to red. Can someone help me achieve this? The code is linked to a data ...

Drag multiple objects in three.js

I created a 3D space using Three.js, similar to the example shown here. My goal now is to allow users to select and drag multiple objects simultaneously. I'm questioning whether I can modify the existing example to achieve this or if I need to start ...

Combining the results of two separate API requests using jQuery/ajax

Hello there, Internet World! This is my first post here, so please be kind. I have gained a lot of valuable knowledge from this site so far, and now I am in need of some help. I have experimented with various code variations such as $when & $then, fu ...

Capture only the QR Code section of an image by cropping it

Currently working on a web project that requires scanning a QR code using the camera on the device. Unfortunately, iOS does not allow direct access to the camera for this purpose, so we have resorted to uploading a picture of the QR code instead. The prob ...

Executing Javascript on Selenium RC with PHP is a crucial skill to have in your toolkit

Is there a way to execute Javascript from Selenium RC? I have been trying different methods with no success so far. I attempted the following approach: I created a custom function in user-extensions.js: function sayhello() { document.write('hel ...

Updating the array in React state does not work properly

Update: Visit the Snack Expo for the latest version. I have a page that displays a list. When I click on a Delete button, my goal is to remove the item with a specific id from the list. The code snippet is shown below: import { useState, memo, useCallbac ...

Make the download window appear automatically when downloading a file

How can I use JavaScript/TypeScript to prompt the browser to open the download window? My goal is to give users the ability to rename the file and select the download folder, as most downloads are saved directly in the default location. This is how I curr ...

Organize information according to the size of the window

I am in need of reorganizing some content based on the size of the window or screen. This is how it appears in full view: https://i.sstatic.net/EInnS.png But here's what I want when the screen size is 768 pixels or less: https://i.sstatic.net/N1ky0 ...

Checking for the Presence of a Word in a String Using jQuery

I'm currently developing an application that allows users to click on usernames to add them to a reply list. The issue I am facing is that if a user with a similar username is already added, the system mistakenly identifies the new username as already ...

Is there a way to ajax just specific HTML table rows instead of transmitting all the form inputs?

For weeks, I've been struggling to use AJAX POST with a JSP script to update my HTML table rows without success. Can anyone provide guidance on this? Below is what I have attempted so far. window.addEventListener("DOMContentLoaded", function () { ...

Unable to launch webpack due to webpack not being detected

When attempting to start webpack, I entered the following command: npm run dev This was done in the command shell where my project and node_modules are located. Upon running the command, an error appeared in the terminal: > clear; npm run --silent so ...

Using Three.js to render JSON models multiple times

Is there a way to load a JSON model just once and then add it to the scene multiple times? I am currently calling the model loading function twice, but I believe there might be a more efficient solution out there. If anyone has a working example or sugges ...

What is the best method for excluding undefined values from arrays in javascript?

let values = dataSku.map(sku => {return map.skuInfo[sku].description}) If map.skuInfo[sku] can potentially be null or undefined, how can I filter it out? ...