# vue-component-type-helpers

NPM version License

Helper utilities for extracting types such as props, slots, attrs, emit, and exposed from Vue component types. No runtime dependencies; provides TypeScript type definitions only. ## Installation ```bash npm install vue-component-type-helpers ``` ## Type Helpers ### `ComponentProps` Extracts the props type of a component. ```typescript import type { ComponentProps } from 'vue-component-type-helpers'; import MyComponent from './MyComponent.vue'; type Props = ComponentProps; ``` ### `ComponentSlots` Extracts the slots type of a component. ```typescript import type { ComponentSlots } from 'vue-component-type-helpers'; import MyComponent from './MyComponent.vue'; type Slots = ComponentSlots; ``` ### `ComponentAttrs` Extracts the attrs type of a component. ```typescript import type { ComponentAttrs } from 'vue-component-type-helpers'; import MyComponent from './MyComponent.vue'; type Attrs = ComponentAttrs; ``` ### `ComponentEmit` Extracts the emit function type of a component. ```typescript import type { ComponentEmit } from 'vue-component-type-helpers'; import MyComponent from './MyComponent.vue'; type Emit = ComponentEmit; ``` ### `ComponentExposed` Extracts the instance type exposed via `defineExpose`. ```typescript import type { ComponentExposed } from 'vue-component-type-helpers'; import MyComponent from './MyComponent.vue'; type Exposed = ComponentExposed; ``` ## Example Given the following component: ```vue ``` Using type helpers: ```typescript import type { ComponentProps, ComponentSlots, ComponentEmit, ComponentExposed } from 'vue-component-type-helpers'; import MyComponent from './MyComponent.vue'; type Props = ComponentProps; // { title: string; count?: number } type Slots = ComponentSlots; // { default(props: { item: string }): any; header(): any } type Emit = ComponentEmit; // { (e: 'update', value: string): void; (e: 'close'): void } type Exposed = ComponentExposed; // { reset: () => void } ``` ## License [MIT](https://github.com/vuejs/language-tools/blob/master/LICENSE) License