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

Export type DefineComponent #12748

Closed
kingyue737 opened this issue Aug 16, 2022 · 1 comment
Closed

Export type DefineComponent #12748

kingyue737 opened this issue Aug 16, 2022 · 1 comment

Comments

@kingyue737
Copy link

What problem does this feature solve?

Most Vue 2 third-party libraries do not provide types for components. Therefore, they cannot profit type checking and intellisense provided by Volar. It may be good to export type DefineComponent just like in Vue 3, so that users can manually shim component types or create PR to add TypeScript support for those Vue2 libraries without changing source code written in Vue <= 2.6.

What does the proposed API look like?

To manually define type of a component in Vue 2.7, we can:

import type { DefineComponent, VNode } from 'vue'

declare module '@vue/runtime-dom' {
  export interface GlobalComponents {
    MyComponent: DefineComponent<
      Props,
      {
        $scopedSlots: {
          slotName: ({args: {propName: propType}}) => VNode[]
        }
      },
      {},
      {},
      Methods
    >
  }
}
@frankykubo
Copy link

Does this have a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants