Skip to content

JSDoc examples for augmenting global properties and custom options differ from docs #11605

Closed
@romansp

Description

@romansp

Vue version

3.4.37

Link to minimal reproduction

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnA3nAwhcEB2K+MWArgM4y4AKUEqswK5cAvnAGZ0hwDkAbqRS8A3EA

Steps to reproduce

  1. Open typescript playground
  2. Hover over ComponentCustomProperties or ComponentCustomOptions and inspect @example

What is expected?

Example should say to augment vue module as stated in docs https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties. For instance

declare module 'vue' {
  interface ComponentCustomProperties {
    $router: Router
  }

  interface ComponentCustomOptions {
    beforeRouteUpdate?(
      to: Route,
      from: Route,
      next: () => void
    ): void
  }
}

What is actually happening?

Example instructs to augment @vue/runtime-core module.

System Info

No response

Any additional comments?

Augmentation docs were updated in this commit vuejs/docs@92f1b4b but it seems this was never reflected in JSDoc of ComponentCustomProperties or ComponentCustomOptions types.

This was discovered after vue-router migrated to correct way of augmentation in 4.4.1 https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#441-2024-07-31 and this caused some disruption in type checking when combined with other packages that use vue/runtime-core augmentation.

Willing to work on PR for this.

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