{"name":"vue-component-type-helpers","version":"1.3.12","license":"MIT","_id":"vue-component-type-helpers@1.3.12","homepage":"https://github.com/vuejs/language-tools#readme","bugs":{"url":"https://github.com/vuejs/language-tools/issues"},"dist":{"shasum":"9e929af242bdbb5e0efc28b739e8e79fb9807781","tarball":"http://registry-npm.ywwl.com/vue-component-type-helpers/download/vue-component-type-helpers-1.3.12.tgz","fileCount":3,"integrity":"sha512-AuUcR/pzdQo37J9Y87cF21F8DLoeaanvb3nj1bzLIHENfKOEhLms2iPNZlaKHwjbXXh7hLvaP/kakUBmLzDbYQ==","signatures":[{"sig":"MEUCIQCucIs4iIyNQ7G3zC0WzPuWnbMUiO4Ap3Id9ThoEDyUHgIgTZ7wmcLL72MRRqNDRShlffTh3ZRv7R9c5QQmjYTvnqo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2079,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkMv50ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoSRQ//Wwb2RQ8as7BsVQpbyM0egbcHtZoYYLQrFs04szDrTQ1afr/Z\r\nsmeida2J0i8dkkUdcwfJlxDnEaaEVH5UiB1rBrJTAe6Ldnhb+hIZe/TyxOFB\r\nYEwzJc1qkkzc7YpHj77+LRNWN+gJIWbz1YSYop91beR48HbR9hrWwpOtAnsW\r\ny+qDtlCpbj5bhIldAwF43tWUfHHtmpbh3DT8QgVR45MqTgzcq0tZrz36kXEc\r\n7dsZKmwJY1dZ0R77AlxTYXW9C6oBMv9nzjuhZis/8ETAN29BMMd4AcYY8Jwh\r\nVw5XkmR87i/XoS2F3P1I/l4+2Sk5kKepMe6FIuGH66oIv/kBGw0aIhPT0LgF\r\nq/QqU3ahU0tV/nbYdI0rRIFJesZgnlfbbdZzPuT5mcMDRTHKo6EX7vVKy9lW\r\ntUMHg9tHEowuaF3PR7TIET/3Sh7RkBD50HmbHvYtGtq5Xu0j1UvoF0p5T3Hx\r\ndOwFFpJrt5YPuQmKudRhBfW0Og5jsOswx9c+fNqNcwFXdiGnJilTcSY1u+Tg\r\nlbvmKI40GovOW70ZvHKwitpS8U/OY1RldUNWwek21NH6mOwaGPmSIG1bdFuh\r\n1wF3EP9AbG/xLVcYhqyvyaPApY1Dk52vqbb3X0T1x7s17ek3ZKJBUQH+E7tS\r\njMR7pbi1cxpgk+T53697w320N2E09g4/kmU=\r\n=j2fq\r\n-----END PGP SIGNATURE-----\r\n","size":1142,"noattachment":false,"key":"/vue-component-type-helpers/-/vue-component-type-helpers-1.3.12.tgz"},"types":"./index.d.ts","gitHead":"7fd019c8ed6ccfcee5fb286b5bb52f88e34443ce","_npmUser":{"name":"johnsoncodehk","email":"johnsoncodehk@gmail.com"},"repository":{"url":"git+https://github.com/vuejs/language-tools.git","type":"git","directory":"packages/vue-component-type-helpers"},"_npmVersion":"8.19.3","directories":{},"_nodeVersion":"18.13.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/vue-component-type-helpers_1.3.12_1681063540662_0.6437952929147239","host":"s3://npm-registry-packages"},"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":1681063540820,"maintainers":[{"name":"johnsoncodehk","email":"johnsoncodehk@gmail.com"}],"_cnpm_publish_time":1681063540820,"dist-tags":{"latest":"3.3.13","v3.0":"3.0.11"}}