vue-component-type-helpers 1.3.13 → 1.3.14-patch.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +26 -0
  2. package/index.d.ts +9 -9
  3. package/package.json +2 -3
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # vue-component-type-helpers
2
+
3
+ Some very simple type helpers used behind `vue-component-meta` for extract component props, slots, emit, exposed types.
4
+
5
+ ## Usage
6
+
7
+ ```vue
8
+ <template>
9
+ <slot name="header" :num="123" />
10
+ <slot name="footer" str="abc" />
11
+ </template>
12
+
13
+ <script lang="ts" setup>
14
+ defineProps<{
15
+ msg: string
16
+ }>()
17
+ </script>
18
+ ```
19
+
20
+ ```ts
21
+ import HelloWorld from './HelloWorld.vue'
22
+ import { ComponentProps, ComponentSlots } from 'vue-component-type-helpers'
23
+
24
+ type Props = ComponentProps<typeof HelloWorld> // { msg: string }
25
+ type Slots = ComponentSlots<typeof HelloWorld> // { header(_: { num: number; }): any; footer(_: { str: string; }): any; }
26
+ ```
package/index.d.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  export type ComponentProps<T> =
2
- T extends (props: infer P) => any ? P :
3
- T extends new () => { $props: infer P } ? P :
2
+ T extends (props: infer P, ...args: any) => any ? P :
3
+ T extends new () => { $props: infer P } ? NonNullable<P> :
4
4
  {};
5
5
 
6
6
  export type ComponentSlots<T> =
7
- T extends (props: any, ctx: { slots: infer S }) => any ? S :
8
- T extends new () => { $slots: infer S } ? S :
7
+ T extends (props: any, ctx: { slots: infer S }, ...args: any) => any ? NonNullable<S> :
8
+ T extends new () => { $slots: infer S } ? NonNullable<S> :
9
9
  {};
10
10
 
11
11
  export type ComponentEmit<T> =
12
- T extends (props: any, ctx: { emit: infer E }) => any ? E :
13
- T extends new () => { $emit: infer E } ? E :
12
+ T extends (props: any, ctx: { emit: infer E }, ...args: any) => any ? NonNullable<E> :
13
+ T extends new () => { $emit: infer E } ? NonNullable<E> :
14
14
  {};
15
15
 
16
16
  export type ComponentExposed<T> =
17
- T extends (props: any, ctx: { expose(exposed?: infer E): any }) => any ? E :
17
+ T extends (props: any, ctx: { expose(exposed: infer E): any }, ...args: any) => any ? NonNullable<E> :
18
18
  T extends new () => infer E ? E :
19
19
  {};
20
20
 
@@ -23,6 +23,6 @@ export type ComponentExposed<T> =
23
23
  */
24
24
 
25
25
  export type Vue2ComponentSlots<T> =
26
- T extends (props: any, ctx: { slots: infer S }) => any ? S :
27
- T extends new () => { $scopedSlots: infer S } ? S :
26
+ T extends (props: any, ctx: { slots: infer S }, ...args: any) => any ? NonNullable<S> :
27
+ T extends new () => { $scopedSlots: infer S } ? NonNullable<S> :
28
28
  {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-component-type-helpers",
3
- "version": "1.3.13",
3
+ "version": "1.3.14-patch.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "*.d.ts"
@@ -9,6 +9,5 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/vuejs/language-tools.git",
11
11
  "directory": "packages/vue-component-type-helpers"
12
- },
13
- "gitHead": "f1f2e7de96e46599a2c84c801f43ecf91d08d4b7"
12
+ }
14
13
  }