Skip to content

TypeScript error with using VTooltip.enabled on 2.1.0 #601

@connorshea

Description

@connorshea

Sorry to open an issue immediately after releasing a fix for the last one 😬

Essentially, when I run tsc to compile the TypeScript files in my app with v-tooltip 2.1.0, it errors:

Connors-MacBook-Pro-2:vglist connorshea$ yarn run tsc --noEmit
yarn run v1.22.10
$ /Users/connorshea/Programming/vglist/node_modules/.bin/tsc --noEmit
app/javascript/packs/application.ts:40:10 - error TS2339: Property 'enabled' does not exist on type 'PluginFunction<any>'.

40 VTooltip.enabled = window.innerWidth > 768;
            ~~~~~~~


Found 1 error.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is what app/javascript/packs/application.ts looks like in my project:

/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.

import Rails from '@rails/ujs';
import Turbolinks from 'turbolinks';
import * as ActiveStorage from '@rails/activestorage';
import '../src/application.scss';
import TurbolinksAdapter from '../src/turbolinks-adapter';
import Vue from 'vue/dist/vue.esm';
import VTooltip from 'v-tooltip';
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import * as Sentry from '@sentry/browser';
import { Vue as VueIntegration } from '@sentry/integrations';
import _ from "lodash";
import '../src/vue-loader';
import '../src/toggleable-buttons';
import '../src/bulma';
import '../src/settings';

// Load the icons directory so it can be discovered and compiled by webpacker.
// @ts-ignore
require.context('../icons', true);

if (process.env.NODE_ENV === 'production') {
  Sentry.init({
    dsn: process.env.SENTRY_DSN_JS,
    integrations: [
      new VueIntegration({ Vue, attachProps: true })
    ],
    environment: process.env.NODE_ENV
  });
}

Vue.use(TurbolinksAdapter);
Vue.use(VTooltip);
VTooltip.enabled = window.innerWidth > 768;

Rails.start();
Turbolinks.start();
ActiveStorage.start();

This is because VTooltip is defined as having a type of PluginFunction<any>, but no enabled setter exists on that type. So the type definition needs to be updated to properly reflect what the VTooltip class can do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions