Error message in VsCode plugin stating that property 'X' is not found on type '{}' within a Vue 3 template

Currently, I am in the process of setting up my vue-cli project that utilizes the composition API with <script setup> to fully integrate TypeScript. Each time I try to use variables within template tags, VSCode flags errors. I have already installed the Vue Language Features (Volar) v0.39.4 plugin.

I have attempted the following solutions without success:

  • Inclusion of vue-file-import.d.ts
  • Adjustments in tsconfig.json
  • Reloading VSCode

Here's an example of the problem:

// ../src/views/component-a/Main.vue
<template>
 <div>
  {{string}} // This triggers a VSCode error: Property 'string' does not exist on type '{}'.ts(2339)
 </div>
</template>


<script setup lang="ts">
  const string: string = 'wohoo';
</script>

//tsconfig.json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.vue",
    // "src/**/*.tsx",
    // "tests/**/*.ts",
    // "tests/**/*.tsx"
    "x/**/*.ts",
    "x/**/*.tsx"
  ],
  "exclude": [
    "node_modules",
    // "src",
    "tests"
  ]
}


//shims-vue.d.ts
declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

Answer №1

We were able to resolve the issue by reverting back to a previous version of the Volar plugin - specifically v0.34.11 (instead of v0.39.4).

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 determining the defaultValue type in React.context usage

'use client'; import { useState, createContext, useMemo } from 'react'; type MessageStatus = 'default' | 'success' | 'error'; export type MessageProps = { type: MessageStatus; payload: string; }; ty ...

"Mastering the Composition API in Vue 3: A guide to defining props within the setup() method

I created a custom "loading state" mixin specifically for Vue 2: export default { props: { loading: { type: Boolean, default: false }, }, data () { return { innerLoading: false, } }, mounted () { this.innerLo ...

angular2 ngif does not effectively conceal HTML elements when set to false

In the HTML file, I have the following code: <p *ngIf="!checklistsready"> not ready </p> <p *ngIf="checklistsready"> Ready </p> And in my TypeScript file, it looks like this: checklistsready: boolean = false; constructor( ...

React application facing a problem with bracket notation in Typescript

After creating a form state to store and update input changes, I encountered an issue: const [form, setForm] = useState({ user: '', email: '', password: '', }); I then wrote a function to handle form changes: const handle ...

What is the process for updating the internal TypeScript version in VS Code?

When using VS Code, I noticed it comes with its own TypeScript version: Is there a way to update this? The current version is 4.9.3. https://i.sstatic.net/vEx85.png ...

The inline style in Angular 2 is not functioning as expected when set dynamically

Having a small dilemma... I'm trying to apply an inline style within a div like this: div style="background: url(..{{config.general.image}})"></div Oddly enough, it was functioning in beta 16 but ever since the RC1 upgrade, it's no longer ...

Images in Angular Firebase causing scroll problems in Chrome

In regard to Angular 6, a common issue arises with slow image loading specifically in Chrome, not other browsers. The project utilizes Firebase and the snapshotchange method to fetch images for the Angular project. Image URLs used are like this: . The iss ...

Developing a typescript React component with a generic callback event handler function passed as a prop

I'm struggling with developing a callback event handler function that can be passed down as a prop to my component. My objective: Allow users to provide a custom callback function that: always accepts the same argument an event (not a react/dom even ...

Send an API request to update a table in a Vue.js application

I am currently learning about VUE and have a simple API request that provides information on bitcoin prices. I would like to update the table every second and am seeking the easiest way to achieve this. Below is the code snippet: async mounted() { const re ...

Adding markers to a map in Angular 2 using ngOnInit after initialization

Embarking on my Angular journey by creating a sample app incorporating GoogleMaps. import { Component, Input, OnInit, Inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { FormControl } from '@ ...

Is there another option for addressing this issue - A function that does not declare a type of 'void' or 'any' must have a return value?

When using Observable to retrieve data from Http endpoints, I encountered an error message stating that "A function whose declared type is neither 'void' nor 'any' must return a value." The issue arises when I add a return statement in ...

Clicking on multiple instances of the same Vue.js component (popover) results in displaying identical data

Attempting to display an AJAX response in a popover shown by clicking an icon (a custom Vue component) brings about a challenge. The issue arises when there are multiple instances of this component, dynamically rendered through the v-for directive within a ...

What is the method for implementing type notation with `React.useState`?

Currently working with React 16.8.3 and hooks, I am trying to implement React.useState type Mode = 'confirm' | 'deny' type Option = Number | null const [mode, setMode] = React.useState('confirm') const [option, setOption] ...

Facing issues while building Vue on Ubuntu 18.04

While developing an app with nodejs and vue2, everything works smoothly on my local machine (MacBook with M1 chip) during the development process. However, when I try to run the build process on Ubuntu, the system starts hanging and requires a reboot. Ther ...

Vue.js 3 - "The 'createStore' export could not be located in the 'vuex' package"

Whenever I run my app, I encounter the following error: WARNING Compiled with 1 warnings ...

Customize your Algolia search widgets in Vue InstantSearch with the power of slots!

Trying to modify the layout of an InstantSearch widget designed for Vue. Upon reviewing the documentation (), it is suggested that using the scope-slot would allow complete override of the widget's DOM output: https://i.sstatic.net/abezM.png Howeve ...

Can the hexadecimal value from an input type color be extracted and used to populate form fields that will then be displayed in a table after submission?

Hello everyone, I'm new to this platform and seeking guidance on how to improve my post! I recently created a CRUD app using Angular. It consists of a basic form with 4 fields, a color picker using input type='color', and a submit button. U ...

Utilizing a Vue2 component within a Vite/Vue3 application

Currently, I am utilizing Vite/Vue3 with TypeScript and I have a desire to incorporate the Vue2 component found at: https://github.com/tylerkrupicka/vue-json-component Upon importing it using the following statement: import JSONView from 'vue-json-co ...

Error Encountered in Vite Production - Content Mismatch The website at 'https://example.herokuapp.com/' was accessed over HTTPS, however, an unsecured stylesheet was requested

I recently deployed a Laravue application on Heroku, and encountered the following error: Mixed Content: The page at 'https://example.herokuapp.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://example.herokuapp.com ...

Developing a project using npm and Node.js with Typescript has been smooth sailing so far. However, an issue has arisen

Recently, I came across a helpful guide on setting up a Node.js project in Typescript on this website: https://basarat.gitbooks.io/typescript/docs/quick/nodejs.html The guide also provides instructions for auto-recompilation upon changes when using npm st ...