Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
romansp opened this issue Aug 13, 2024 · 1 comment · Fixed by #11609
Closed

Comments

@romansp
Copy link
Contributor

romansp commented Aug 13, 2024

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.

@edison1105
Copy link
Member

@romansp
The JSDoc should align with the docs.
PR welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants