Vuetify 2 Type Issue: Unable to locate reference to 'DefaultProps'

Ever since I updated my project to utilize the latest 2.x release of Vuetify (https://vuetifyjs.com), I've been encountering Type Errors during compilation and I'm unsure of how to resolve them. It seems like there might be an issue with my tsconfig configuration.

I carefully reviewed the documentation and made sure to include Vuetify in the types section of my tsconfig.json as shown below:

{
  "compilerOptions": {
    ...

    "types": [
      "webpack-env",
      "jest",
      "vuetify",
      "axios"
      ],

     ...
  }
}

My code is quite straightforward:

import Vue from 'vue';
import App from './App.vue';
import vuetify from './plugins/vuetify';
import router from './router';
import store from './store';

Vue.config.productionTip = false;

new Vue({
  vuetify,
  router,
  store,
  render: (h) => h(App),
}).$mount('#app');

I then run the dev server with: yarn serve

ERROR in /Users/sebe/workspace/app/frontend/arena/src/main.ts
12:3 Argument of type '{ vuetify: Vuetify; router: VueRouter; store: Store<any>; render: (h: CreateEle
ment) => VNode; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, Def
aultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.
  Object literal may only specify known properties, and 'vuetify' does not exist in type 'ComponentOpt
ions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>
, Record<string, any>>'.
     8 | 
     9 | new Vue({
  > 10 |   vuetify,
       |   ^
    11 |   router,
    12 |   store,
    13 |   render: (h) => h(App),

ERROR in /Users/sebe/workspace/app/node_modules/vuetify/types/index.d.ts
59:10 Cannot find name 'DefaultData'.
    57 |   export interface ComponentOptions<
    58 |     V extends Vue,
  > 59 |     Data=DefaultData<V>,
       |          ^
    60 |     Methods=DefaultMethods<V>,
    61 |     Computed=DefaultComputed,
    62 |     PropsDef=PropsDefinition<DefaultProps>,

The same error occurs for DefaultProps, PropsDefinition, DefaultComputed, and DefaultMethods.

Any assistance would be highly appreciated :)

UPDATE: I just realized that I encounter the same errors using the default Vuetify TypeScript template:

vue create newapp
vue add vuetify
yarn serve

Here's what my ./plugins/vuetify.ts file looks like:

import Vue from 'vue';
import Vuetify from 'vuetify/lib';
import colors from 'vuetify/lib/util/colors';
import { VuetifyPreset } from 'vuetify/types/presets';

Vue.use(Vuetify);

const opts: Partial<VuetifyPreset> = {
  theme: {
    dark: true,
    themes: {
      light: {
        primary: colors.green.base,
      },
      dark: {
        primary: colors.green.darken2,
      },
    },
  },
  icons: {
    iconfont: 'mdi',
  },
};

export default new Vuetify(opts);

Answer №1

Looking through the Vuetify source code:

export default Vuetify
export interface Vuetify

The confusion arises because both the module and the interface are named Vuetify.

Typescript tends to retrieve the module of Vuetify instead of its interface.

To resolve this issue:

import { Vuetify } from 'vuetify'

Include this line in your main.ts file

Answer №2

After encountering a similar issue, I discovered that the cause was due to a symbolic link in the directory:

/c/linkToDev/vueApp consistently resulted in failure.

/d/devFolder/vueApp on the other hand, always functioned properly.

Answer №3

Dealing with a similar issue, I found a workaround by incorporating the vuetify-loader WebPack plugin into my Vuetify setup.

To resolve it, I made a small adjustment in my main.ts file:

import vuetify from '@/plugins/vuetify.js'; 
import Vuetify from 'vuetify';

Following a strategy akin to @shuixiya1999's approach, this tweak successfully resolved the problem for me at this moment.

Here is the updated configuration specifications:

    "vue": "2.6.14",
    "vuetify": "^2.6.7",
    "vuetify-loader": "^1.7.3", 

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

methods for array filtering in typescript

How do I filter an array in TypeScript? I attempted the following findAllPersonsNotVisited():Observable<Person[]> { var rightNow = new Date(); var res = rightNow.toISOString().slice(0,10).replace(/-/g,"-"); return this.db.list(& ...

Mastering Vue Transitions: The Ultimate Guide to Creating a Seamless One-Time Animation Experience

I'm currently working on a Vue app for taking notes. The note being edited is automatically saved every few seconds. After each autosave, I want to display a brief message at the bottom of the screen that says "Note Saved". This message should fade in ...

A TypeScript class designed to serve as a function type as well

When trying to utilize angular's IHttpService, I am unsure of how to manage the following function. interface IHttpService { <T>(config: IRequestConfig): IHttpPromise<T>; } class MyHttpService implements IHttpService { // The cod ...

Transitioning from Angular Http to HttpClient: Overcoming Conversion Challenges

Currently, I am in the process of converting my old Angular app from Http to HttpClient. While working on the service.ts section, I encountered an error that I am struggling to resolve: ERROR Error: Cannot find a differ supporting object '[object Ob ...

Can you explain the process of utilizing Angular databinding to display nested information?

I'm facing a challenge with databinding when working with nested arrays in multiple timeslots and windows. Despite understanding the basics, I can't seem to make it work no matter how I try different approaches. It's really frustrating not k ...

Successfully providing proper types to Redux reducers

I'm struggling with providing a suitable action type to my reducer function in Redux while using Typescript. In regular ES6 syntax, I would simply pass an empty object as the type like this: action: {} However, Typescript requires a more specific ac ...

VueJS 3: "The 'default' export (imported as 'Vue') could not be found in the 'vue' library."

main.js import Vue from 'vue' import Vuex from "vuex" import { createApp } from 'vue' import App from './App.vue' import store from "./store" import drizzleVuePlugin from "@drizzle/vue-plugin" import drizzleOptions from "./dri ...

`Unresponsiveness in updating bound property after change in Angular2 child property`

Having trouble with my custom directive and ngOnChanges() not firing when changing a child property of the input. my.component.ts import {Component} from 'angular2/core'; import {MyDirective} from './my.directive'; @Component({ d ...

When attempting to save my submission object data to the database, TypeORM unexpectedly alters the information

I am encountering an issue with inserting my data into a database using TypeORM The problem at hand is as follows: What needs to be sent to the database includes the following data: Title, Description, Userid, idCategoryService, and createdBy. The ids and ...

Ways to determine the generic type of a property value from a decorated property within a decorator

While experimenting with some code, I encountered an issue where the generic type of a property value wasn't being resolved correctly when changing from TValue to (t: TValue) => TValue. Instead of being recognized as the expected number, it was now ...

Is there a way to eliminate the legend symbol for just one legend in Highcharts?

Looking to customize a legend in Highcharts but facing limitations due to Plot Lines and Bands not having legends. To work around this, I have added an empty series that acts as a toggle for showing/hiding plot lines. Since my plot lines are vertical, I im ...

Adding dynamic URLs to the canonical tags in Next.js version 14.2.4: A comprehensive guide

I'm currently facing an issue with implementing dynamic URLs in my Next.js dynamic routes. To generate metadata, I am utilizing a server-rendered page: export const metadata: Metadata = { title: `InterviewQA | ItsIndianGuy`, description: ...

The module "@nestjs/config" does not have a member named "ConfigModule" available for export

Currently utilizing NestJS, I added the @nestjs/config module by executing the following command: npm i --save @nestjs/config Encountered this error: The module '"@nestjs/config"' does not have an exported member 'ConfigModule&apo ...

The issue of duplicate items being stored in an array arose when inserting a new element

I am new to angular and currently working on an application that allows users to take notes and store them in a database. However, I have encountered a problem during the note addition process. When there are no existing notes in the database and I add tw ...

Using Ionic2 and Angular2 to access a custom configuration file

Currently, I am tackling a project in ionic2 and I have come across the need to generate a fresh custom JSON configuration file. While there are tutorials available that demonstrate creating one and accessing it through http.get, I find it quite odd to ret ...

"Trouble with socket.io: events failing to dispatch to other users within the

Currently, I am investigating the behavior of a basic socket.io application. To test this, I have two tabs representing different users, and I am checking if one user receives events triggered by the other. Surprisingly, neither frontend receives the event ...

Custom Email Template for Inviting Msgraph Users

I'm currently exploring the possibility of creating an email template for the MS Graph API. I am inviting users to join my Azure platform, but the default email they receive is not very visually appealing. public async sendUserInvite(body: {email: < ...

Update the product data in a VueJS application by modifying the fields in MongoDB using the ObjectID provided in the PATCH request

Trying to wrap my head around this one - I'm working on a fullstack app using MongoDB, NestJS, and VueJS. The app involves a form that adds various products to a MongoDB database. The current issue I'm grappling with is the ability to edit each ...

Storing basic input values for a function

I am currently working on developing a versatile method that is capable of accepting any number of parameters, while storing the input type for future use. Let's take a look at an example: const customizedFunction = <A extends any[]>(innerFunct ...

What is a more definitive way to define a variable other than using const?

One of my components, called NoteComponent, emits a message called note-not-saved. To handle this message, I have the following code: <template> (...) <NoteComponent @note-not-saved='() => noteNotSaved=true' /> (...) </templ ...