Skip to content

Importing Buefy erases types other global component properties #4232

Description

@ElteHupkes

Overview of the problem

Buefy version: [3.0.1]
Vuejs version: [3.5.18]
OS/Browser: (irrelevant)
IDE: PhpStorm 2025.2 for the screenshots

Description

The problem is best illustrated by a screenshot:

Image

And with Buefy commented out:

Image

Steps to reproduce

  1. Create a new Vue project using npm create vue@latest, enabling TypeScript, the router and the sample code.
  2. Open the project in WebStorm / PHPStorm.
  3. In any component, you can use $router and the IDE understands what you mean (screenshot 1).
  4. Now import Buefy from "buefy" in any typescript file. You don't even need to include it anywhere.
  5. The IDE no longer understands $router (screenshot 2).

Expected behavior

Screenshot 1

Actual behavior

Screenshot 2 😉

Suggested fix

I have no experience with Vue plugin development, but Buefy's vue-augmentation.js adds the global type definitions in this way:

// Augments the global property with `$buefy`.
// https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties
declare module '@vue/runtime-core' {
    /* @public */
    interface ComponentCustomProperties {
        /* Global Buefy API. */
        $buefy: {
            config: typeof ConfigComponent,
            globalNoticeInterval?: ReturnType<typeof setTimeout>,
            dialog: DialogProgrammatic,
            loading: LoadingProgrammatic,
            modal: ModalProgrammatic,
            notification: NotificationProgrammatic,
            snackbar: SnackbarProgrammatic,
            toast: ToastProgrammatic
        }
    }
}

The documentation the comment links to instead suggests doing this (which is incidentally also what vue-i18n and vue-router do):

// Augments the global property with `$buefy`.
// https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties
declare module 'vue' { // <-- 'vue' instead of '@vue/runtime-core'
    /* @public */
    interface ComponentCustomProperties {
        /* Global Buefy API. */
        $buefy: {
            config: typeof ConfigComponent,
            globalNoticeInterval?: ReturnType<typeof setTimeout>,
            dialog: DialogProgrammatic,
            loading: LoadingProgrammatic,
            modal: ModalProgrammatic,
            notification: NotificationProgrammatic,
            snackbar: SnackbarProgrammatic,
            toast: ToastProgrammatic
        }
    }
}

And indeed, when I monkey patch buefy.d.ts with that change, the issue is resolved:

Image

I'll create a PR shortly, but I wanted to write up and raise the issue first. PR #4233

Activity

  1. added a commit that references this issue on Aug 21, 2025
    9a255dc
  2. added a commit that references this issue on Aug 24, 2025
    2e34f96
  3. added 2 commits that reference this issue on Aug 24, 2025
    962041c
    520b887
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions