Skip to content

Commit

Permalink
feat: 更新组件属性类型
Browse files Browse the repository at this point in the history
  • Loading branch information
agileago committed Dec 23, 2021
1 parent ed2fb9b commit 72048a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions example/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Autobind, Mut, VueComponent, VueService } from 'vue3-oop'
import { Autobind, ComponentProps, Mut, VueComponent, VueService } from 'vue3-oop'
import { onBeforeUnmount } from 'vue'

class PositionService extends VueService {
Expand All @@ -18,7 +18,13 @@ class PositionService extends VueService {
}
}

class Foo extends VueComponent {
interface Foo_Props {
name?: string
size?: number
}

class Foo extends VueComponent<Foo_Props> {
static defaultProps: ComponentProps<Foo_Props> = ['size', 'name']
postionService = new PositionService()

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type TransformModelValue<T extends {}> = 'v-model:modelValue' extends key
? Omit<T, 'v-model:modelValue'> & { ['v-model']?: T['v-model:modelValue'] }
: T

export type ComponentProps<T extends {}> = ComponentPropsArray<T> | ComponentPropsObject<T>
export type ComponentProps<T extends {}> = ComponentPropsObject<T> | Array<keyof Omit<T, 'slots'>>

export type ComponentPropsObject<T extends {}> = {
[U in keyof Omit<T, 'slots'>]-?: Prop<any>
Expand Down

0 comments on commit 72048a2

Please sign in to comment.