The declaration file for module 'vue-tabulator' was nowhere to be found

Trying to incorporate the vue-tabulator Vue component from https://github.com/angeliski/vue-tabulator into a basic Vue application written in TypeScript.

main.ts:

import Vue from 'vue'
import VueTabulator from 'vue-tabulator'
import App from './App.vue'

Vue.config.productionTip = false

Vue.use(VueTabulator)

new Vue({
  render: h => h(App)
}).$mount('#app')

App.ts:

import { Component, Vue } from 'vue-property-decorator'

@Component
export default class App extends Vue {}

App.vue:

<template>
  <div id="app">
    <h1>Kewl</h1>
  </div>
</template>

<style scoped>
</style>

<script lang="ts" src="./App.ts">
</script>

Encountered an error while running the application using npm run serve:

 ERROR  Failed to compile with 1 errors                                                                                                                     2:23:19 PM
This dependency was not found:

* tabulator-tables in ./node_modules/vue-tabulator/dist/vue-tabulator.common.js

To install it, you can run: npm install --save tabulator-tables
Type checking in progress...
ERROR in C:/Users/eperret/Desktop/tabulator-tests/src/main.ts(2,26):
2:26 Could not find a declaration file for module 'vue-tabulator'. 'C:/Users/eperret/Desktop/tabulator-tests/node_modules/vue-tabulator/dist/vue-tabulator.umd.js' implicitly has an 'any' type.
  Try `npm install @types/vue-tabulator` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-tabulator';`
    1 | import Vue from 'vue'
  > 2 | import VueTabulator from 'vue-tabulator'
      |                          ^
    3 | import App from './App.vue'
    4 | 
    5 | Vue.config.productionTip = false
Version: typescript 3.5.3
Time: 3055ms

Lastly, here's the content of packages.json:

{
  "name": "tabulator-tests",
  "version": "0.1.0",
  "private": true,
  ...
}

The solution provided in this thread didn't seem to resolve the issue faced.

Any suggestions on how to proceed?

[EDIT 1]

Attempted to install TypeScript types for vue-tabulator, but no such package seems to be available:

npm install @types/vue-tabulator
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fvue-tabulator - Not found
...

[EDIT 2]

Regarding shims, there are two related files in the src folder:

shims-tsx.d.ts:

import Vue, { VNode } from 'vue'

declare global {
  namespace JSX {
    // tslint:disable no-empty-interface
    interface Element extends VNode {}
    // tslint:disable no-empty-interface
    interface ElementClass extends Vue {}
    interface IntrinsicElements {
      [elem: string]: any
    }
  }
}

shims-vue.d.ts:

declare module '*.vue' {
  import Vue from 'vue'
  export default Vue
}

Answer №1

Try installing @types for the 'vue-tabulator' package first. If it doesn't exist, you can create a shim file for type declarations for 'vue-tabulator.'

The issue is likely due to using TypeScript (TS) in your project while the 'vue-tabulator' package only supports JavaScript (JS) version.

Instructions for adding shims:

  1. Create a folder called 'shims' inside the src folder of your project
  2. Make a new file with a name like 'shims-tabulator.d.ts'
  3. Copy and paste the code 'declare module 'vue-tabulator';' into that file
  4. Restart your project

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

What is the best way to implement the 'param' in a Laravel view's click

When working with Laravel Spark, I am attempting to include a parameter in the click event of the registration form. The default button looks like this: <button class="btn btn-primary" @click.prevent="register" :disabled="registerForm.busy"> While ...

What is the best way to remove a parent app.js element from a child component?

When I click the delete button, my intention is to filter an array in the parent app.js component and remove a specific item. However, I keep encountering a Typescript error stating Cannot assign to read only property 'message' of object 'Sy ...

The application logs are not displayed on the Pm2 dashboard

My node.js APIs are running on pm2 and I'm monitoring them using the pm2 dashboard. When I access the APIs through ssh, I can view the application logs by running the command: pm2 logs However, I'm facing an issue where I cannot view these logs ...

How to display currency input in Angular 2

Is there a way to dynamically format input as USD currency while typing? The input should have 2 decimal places and populate from right to left. For example, if I type 54.60 it should display as $0.05 -> $0.54 -> $5.46 -> $54.60. I found this PLUN ...

The Type X is lacking essential properties found in Type Y, including length, pop, push, concat, and an additional 26 more properties. Code: [2740]

One interesting thing I have noticed is the Product interface: export interface Product{ code: string; description: string; type: string; } There is a service with a method that calls the product endpoint: public getProducts(): Observable<Product ...

Could it be that Vue component slots are not seen as direct descendants?

Imagine I have a main component called Tabs, which accepts child Tab Components as slots. Here is how the structure looks like: Tabs (Parent) <div> <slot name="tabChild"> </div> Tab (Child) <div> Tab {{name}} </div> ...

Encountering a maximum call stack size error in Nuxtjs during development mode, and a server error 500 in production, instead of being redirected to a custom error page,

Whenever I input a URL that doesn't exist, I often encounter my personalized error message but sometimes I receive a server error (Image) Here is the content of my error.vue page : <template> <div class="error-page"> <d ...

Run JavaScript code whenever the table is modified

I have a dynamic table that loads data asynchronously, and I am looking for a way to trigger a function every time the content of the table changes - whether it's new data being added or modifications to existing data. Is there a method to achieve th ...

Custom web addresses for files in the Vue 2.1 framework

After going through the documentation for Vue Router, it seemed like setting up redirects should be straightforward, but I'm having trouble making it work. My first attempt was to reference a file in S3: { path: '/rules', redirect: &ap ...

Exploring Angular2: The Router Event NavigationCancel occurring prior to the resolution of the Route Guard

My application has routes protected by an AuthGuard that implements CanActivate. This guard first checks if the user is logged in and then verifies if certain configuration variables are set before allowing access to the route. If the user is authenticated ...

Connecting Vue.JS page to my existing HTML page: A step-by-step guide

While developing my website, I faced a challenge with the structure. The home page was built using traditional HTML/CSS, while the other pages were created in Vue.js. Is there a method to connect these two different types of files? For instance, can I inc ...

How to create an array of objects using an object

I have a specific object structure: { name: 'ABC', age: 12, timing: '2021-12-30T11:12:34.033Z' } My goal is to create an array of objects for each key in the above object, formatted like this: [ { fieldName: 'nam ...

How to implement debouncing for an asynchronous custom validator in Vue.js using vuelidate?

I encountered an issue with my validator function that checks if a username is already registered in the database. The problem was that the request was being sent to the server after every single character input, which was far too frequent. To remedy this, ...

What is the best way to enable external access to a class component method in React and Typescript?

I am currently working on a component library that compiles to umd and is accessible via the window object. However, I need to find a way to call a class component's methods from outside the class. The methods in my classes are private right now, but ...

Restrict the parameter type using a type predicate

How can I effectively narrow types based on the value of a single field in TypeScript? It seems that using type predicates may not be working as expected to narrow down the types of other parameters within a type. Is there a way to ensure correct type na ...

When conditionals are used to infer function parameters in TypeScript, they may end up with the type 'never'

Problem with Typescript Parameter Type Resolution: functionBuilder takes a parameter arg and returns an object with a function property based on the value of arg. If arg === 'a', the function expects a string parameter, otherwise it expects a nu ...

Guide to incorporating a pluck feature into TypeScript code

One task I face frequently is extracting specific properties from an object const obj = {a:1, b: 2, c: 3}; const plucked = pluck(obj, 'a', 'b'); // {a: 1, b:2} Unfortunately, achieving this task with type safety in TypeScript can be c ...

Navigating through JSON object using Angular 2's ngFor iterator

I want to test the front end with some dummy JSON before I write a service to get real JSON data. What is the correct way to iterate through JSON using ngFor? In my component.ts file (ngOnInit()), I tried the following code with a simple interface: var js ...

What sets apart declaring an object within data() versus inside created() in VueJs?

Can you explain the discrepancies in VueJs between these declarations? data() { return { foo = 'bar' } } and this : created() { this.foo = 'bar' } I understand that both can be accessed using 'this' i ...

HttpClient experiences a timeout in processing the request

Currently, I am utilizing TypeScript in conjunction with ASP.NET Core Web API. Situation: I am facing a challenge with a backend data response service that is taking more than two minutes to load the data. It appears that the default timeout for the Http ...