{"name":"vue-component-type-helpers","version":"2.1.10","license":"MIT","sideEffects":false,"repository":{"type":"git","url":"https://github.com/vuejs/language-tools.git","directory":"packages/component-type-helpers"},"gitHead":"b0af30caee2f8dfb1a8393c1b400f38e31fa4883","_nodeVersion":"20.14.0","_npmVersion":"lerna/3.10.0/node@v20.14.0+arm64 (darwin)","_id":"vue-component-type-helpers@2.1.10","dist":{"integrity":"sha512-lfgdSLQKrUmADiSV6PbBvYgQ33KF3Ztv6gP85MfGaGaSGMTXORVaHT1EHfsqCgzRNBstPKYDmvAV9Do5CmJ07A==","shasum":"9f80c56a141e85ec577cf4f0b6965a61b6f1e1ef","tarball":"http://registry-npm.ywwl.com/vue-component-type-helpers/download/vue-component-type-helpers-2.1.10.tgz","fileCount":7,"unpackedSize":4716,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBhifuYEtg0AeRWLUVIFIV32pdsn9INl5bdlzGcrCjQvAiEA/J/NjJy8t8+u+rdl4auBi4xi3JgvU6glxnUTUt4+dJ8="}],"size":2014,"noattachment":false,"key":"/vue-component-type-helpers/-/vue-component-type-helpers-2.1.10.tgz"},"_npmUser":{"name":"johnsoncodehk","email":"johnsoncodehk@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-component-type-helpers_2.1.10_1730314939887_0.3953962677776732"},"_hasShrinkwrap":false,"readme":"# vue-component-type-helpers\n\n<p>\n  <a href=\"https://www.npmjs.com/package/vue-component-type-helpers\"><img src=\"https://img.shields.io/npm/v/vue-component-type-helpers.svg?labelColor=18181B&color=1584FC\" alt=\"NPM version\"></a>\n  <a href=\"https://github.com/vuejs/language-tools/blob/master/LICENSE\"><img src=\"https://img.shields.io/github/license/vuejs/language-tools.svg?labelColor=18181B&color=1584FC\" alt=\"License\"></a>\n</p>\n\nHelper utilities for extracting types such as props, slots, attrs, emit, and exposed from Vue component types. No runtime dependencies; provides TypeScript type definitions only.\n\n## Installation\n\n```bash\nnpm install vue-component-type-helpers\n```\n\n## Type Helpers\n\n### `ComponentProps<T>`\n\nExtracts the props type of a component.\n\n```typescript\nimport type { ComponentProps } from 'vue-component-type-helpers';\nimport MyComponent from './MyComponent.vue';\n\ntype Props = ComponentProps<typeof MyComponent>;\n```\n\n### `ComponentSlots<T>`\n\nExtracts the slots type of a component.\n\n```typescript\nimport type { ComponentSlots } from 'vue-component-type-helpers';\nimport MyComponent from './MyComponent.vue';\n\ntype Slots = ComponentSlots<typeof MyComponent>;\n```\n\n### `ComponentAttrs<T>`\n\nExtracts the attrs type of a component.\n\n```typescript\nimport type { ComponentAttrs } from 'vue-component-type-helpers';\nimport MyComponent from './MyComponent.vue';\n\ntype Attrs = ComponentAttrs<typeof MyComponent>;\n```\n\n### `ComponentEmit<T>`\n\nExtracts the emit function type of a component.\n\n```typescript\nimport type { ComponentEmit } from 'vue-component-type-helpers';\nimport MyComponent from './MyComponent.vue';\n\ntype Emit = ComponentEmit<typeof MyComponent>;\n```\n\n### `ComponentExposed<T>`\n\nExtracts the instance type exposed via `defineExpose`.\n\n```typescript\nimport type { ComponentExposed } from 'vue-component-type-helpers';\nimport MyComponent from './MyComponent.vue';\n\ntype Exposed = ComponentExposed<typeof MyComponent>;\n```\n\n## Example\n\nGiven the following component:\n\n```vue\n<!-- MyComponent.vue -->\n<script setup lang=\"ts\">\ndefineProps<{\n  title: string;\n  count?: number;\n}>();\n\ndefineEmits<{\n  update: [value: string];\n  close: [];\n}>();\n\ndefineSlots<{\n  default(props: { item: string }): any;\n  header(): any;\n}>();\n\nconst internalState = ref(0);\ndefineExpose({\n  reset: () => { internalState.value = 0; },\n});\n</script>\n```\n\nUsing type helpers:\n\n```typescript\nimport type { ComponentProps, ComponentSlots, ComponentEmit, ComponentExposed } from 'vue-component-type-helpers';\nimport MyComponent from './MyComponent.vue';\n\ntype Props = ComponentProps<typeof MyComponent>;\n// { title: string; count?: number }\n\ntype Slots = ComponentSlots<typeof MyComponent>;\n// { default(props: { item: string }): any; header(): any }\n\ntype Emit = ComponentEmit<typeof MyComponent>;\n// { (e: 'update', value: string): void; (e: 'close'): void }\n\ntype Exposed = ComponentExposed<typeof MyComponent>;\n// { reset: () => void }\n```\n\n## License\n\n[MIT](https://github.com/vuejs/language-tools/blob/master/LICENSE) License\n","publish_time":1730314940122,"maintainers":[{"name":"johnsoncodehk","email":"johnsoncodehk@gmail.com"}],"_cnpm_publish_time":1730314940122,"dist-tags":{"latest":"3.3.13","v3.0":"3.0.11"}}