VS Code displays the error message "No suitable overload matches this call" when working with props in Vue.js

I've encountered some strange errors and warnings in VS Code while working on my Vue.js project:

https://i.sstatic.net/sjhVZ.png

  • Odd errors occur when I pass a value as a prop to one of my custom components, but not with Vuetify components
  • The warning only appears on the first prop passed
  • It doesn't matter what type or value is passed to the prop
  • Despite the warnings, the project compiles without errors and functions properly
  • I prefer using the "regular/default" component style over the class-based style
  • My project is built with TypeScript

The example image shows how the prop is defined in the child component:

import Vue from 'vue';

export default Vue.extend({
    name: 'MyCustomComponent',

    props: {
        title: String,
    },

    data: function () {},
});

Is there a way to resolve these "useless" warnings?

Edit

Here are the parent and child component scripts as requested:

App.vue

<template>
    <v-app>
        <v-main>
            <hello-world :title="title" :heading="heading" />
        </v-main>
    </v-app>
</template>

<script lang="ts">
import Vue from 'vue';
import HelloWorld from './components/HelloWorld.vue';

export default Vue.extend({
    name: 'App',

    components: {
        HelloWorld,
    },

    data: () => ({
        title: 'Title!',
        heading: 'Heading!',
    }),
});
</script>

HelloWorld.vue

<template>
    <v-container>
        <v-row class="text-center">
            <v-col class="mb-4">
                <h1>
                    {{ title }}
                </h1>
                <h2>
                    {{ heading }}
                </h2>
            </v-col>
        </v-row>
    </v-container>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
    name: 'HelloWorld',

    props: {
        title: String,
        heading: String,
    },

    data: () => ({}),
});
</script>

Answer №1

It appears that the issue you are facing is likely related to the vue-i18n plugin.

I have created a codesandbox using your code and the latest stack compatible with vue-2, and I did not encounter any warnings.

To resolve this, I recommend comparing your project's package.json with the one in the sandbox and updating any packages that are at a lower version.

You may be using an outdated version of typescript, so I suggest starting by updating it.

If updating typescript does not solve the issue, consider upgrading vue-i18n and checking for any TypeScript plugins/extensions installed in VSCode. You can try disabling or upgrading them as well.


If the above steps do not work, you can implement the following solution:

import { TranslateResult } from "vue-i18n";

export default {
  props: {
        title: [String, TranslateResult],
  },
}

However, with versions like

"vue": "^2.6.14", "vue-i18n": "8.27.1"
, and
"typescript": "~4.5.5"
, this step should not be necessary.


If none of the suggested solutions resolve your problem, consider replicating your project on codesandbox.io or vscode.dev. If you can reproduce the issue there, save and share the link for further assistance.


As a potential resource, here is an older article discussing the challenges involved in integrating vue-i18n with typescript a few years ago: https://medium.com/js-dojo/manage-vue-i18n-with-typescript-958b2f69846f

Answer №2

Encountering the error message No overload matches this call while working on a Vue 2 project in VS-Code with Volar can be frustrating. The solution to this issue lies in ensuring that you have included the necessary dependency @vue/runtime-dom. This crucial step is outlined in the installation instructions found here: https://marketplace.visualstudio.com/items?itemName=Vue.volar. Be sure to have this package installed to avoid running into similar errors.

Answer №3

I encountered a similar issue, but specifically within vuex types. It seems like the problem stemmed from using volar + vscode 1.74.

https://i.sstatic.net/fDVP5.png

https://i.sstatic.net/iiIv5.png

After switching to the community vscodium version 1.73, the problem vanished.

https://i.sstatic.net/llFYg.png

https://i.sstatic.net/nVtIp.png

To address the issue differently, one can try adding

"strictFunctionTypes": false
as a rule in tsconfig.json.

However, I do not recommend this solution as it compromises essential type checks.

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

The Vue components are failing to load

Working with vuejs in laravel has been a bit challenging for me. I've installed npm, vue-router, and vue-axios successfully, but when I try to load my page, I encounter a console error stating: ReferenceError: CreateCategory is not defined, and the pa ...

Guide to dynamically updating a textarea in vue.js by incorporating data from several inputs

Is there a way to update a textarea based on multiple inputs using jQuery and vue.js? I have successfully implemented the jQuery part with line breaks, but when I try to display the value of the textarea elsewhere using vue.js, it doesn't seem to work ...

What is the way to declare a prop as optional in Svelte using TypeScript?

I am facing an issue in declaring an optional prop in Svelte with TypeScript. The error message I receive is "Declaration or statement expected". Can someone guide me on how to correctly declare the prop? Definition of My Type: export enum MyVariants { ...

Barrier Preventing My Access to the Page

Currently, I am working on a vue page that includes a navigation-guard. This particular page serves as an 'Update Details' section where I have implemented the use of beforeRouteLeave. The purpose of this setup is to display a warning modal if an ...

The modifications made in the Vue file are not being reflected in the browser

I am currently involved in a project that utilizes the Laravel and Vue.js technologies. Within this project, there is a form created in a Vue file, and I need to add text to this file. Upon making changes to the Vue file, it seems necessary to rebuild the ...

Avoiding the creation of fields that have not been inputted in TypeGraphQL

@Resolver() export class NameCardCreateResolver { @Mutation(() => BaseMutationResponse) async namecardCreate( @Arg("chosenSNSUrls", () => SNSInput) { facebook, twitter, instagram, blog, youtube }: SNSInput, @Arg("owner& ...

How can I send styles to a child component and utilize them as scoped styles within Vue?

One of my components is a parent: <template> <ChildComponent :styles="styles" /> </template> <script> export default { data: () => ({ styles: ` p { color: red } ` ...

Dynamic component validation is a crucial aspect of the v-validation process

I'm new to Vue.js and I want to implement validation in dynamic components. Here is a snippet of my code: <div class="widget-main padding-6" v-for="serving in servingData"> <div class="form-group col-sm-5"> <label for="form-fie ...

Invoke cloud functions independently of waiting for a response

Attempting a clever workaround with cloud functions, but struggling to pinpoint the problem. Currently utilizing now.sh for hosting serverless functions and aiming to invoke one function from another. Let's assume there are two functions defined, fet ...

Laravel's redirection intended feature is not functioning as expected

I am currently facing an issue with my authentication function that is triggered upon login from a Vue component. The user gets logged in successfully, but there seems to be an issue with the redirect not happening from the controller. I suspect that it mi ...

Utilize a Typescript library within a separate Typescript library

I have a TypeScript library on GitHub that I want to install using npm install --save git+ssh://<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f38362b1d15c3f4">[email protected]</a>:User/mylib.git into my targ ...

Exploring the Power of Jest in Vue Development

Can anyone explain how to use Jest Test for testing the following method? delayedFetch() { setTimeout(() => { this.fetchData(); }, 1000); I attempted using Async and await, but I may be incorrectly implementing it. ...

What is the process for previewing an image in Element UI?

I am currently utilizing the Element UI component el-image. I want to be able to preview an image when it is clicked using :preview-src-list, but upon first click, nothing happens. It only previews the downloaded image after clicking a second time. Is ther ...

Converting an array into an object by using a shared property in each element of the array as the key

I have an item that looks like this: const obj = [ { link: "/home", title: "Home1" }, { link: "/about", title: "About2" }, { link: "/contact", title: "Contact1" } ] as const and I want to p ...

Conventions for Encapsulating Private Properties in Typescript

Query: What is the ideal approach for naming private properties in Typescript and should one always create getters and setters for those properties? After perusing this link, I found myself reconsidering what I previously thought to be a good coding pract ...

The incredible power of the MongoDB $inc field

I am facing a challenge in writing a function that accepts a record id, an action (inc or dec), and a field name as a string to be incremented (can be 'likes', 'subs' or any other). The issue is that I am unable to find a way to replac ...

Error: The module '/@modules/vue.js' does not export a 'default' value as requested by the syntax

I'm encountering an issue with Vee Validate form validation in Vue.js. As a beginner, I am struggling to grasp the import syntax. After installing vee-validate using npm i vee-validate --save and placing it in my node_modules directory, I proceeded to ...

Unable to store the outcomes from [ngbTypeahead] in [resultTemplate]

I'm trying to integrate ngbTypeahead into my HTML using the code snippet below <ng-template #rt let-r="result" let-t="term"> <ngb-highlight [result]="r.FirstName" [term]="t"></ngb-highlight> </ng-template> <input name ...

The VueJS Watcher fails to activate when monitoring changes within nested objects

I have created a codesandbox to demonstrate my issue: codesandbox example watcher not triggering. Currently, I am developing a component that depends on an object with dynamically added data. In a separate .js file, I export the following object: export d ...

Exporting multiple sheets using Angular's ngx-export-as functionality

Currently utilizing ngx-export-as in my Angular project and I am looking to export an Excel file with multiple sheets. How can I achieve this export functionality? I have raised a concern regarding this on GitHub. ...