Skip to content

Commit

Permalink
fix: remove ExtractPropsAndEvents util
Browse files Browse the repository at this point in the history
  • Loading branch information
rudyxu1102 committed Sep 28, 2023
1 parent aa02014 commit 418e2d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions packages/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
Slots,
VNode,
ImgHTMLAttributes,
StyleValue,
ExtractPropsAndEvents
StyleValue
} from 'vue'
import { describe, expectType, IsUnion, test } from './utils'

Expand Down Expand Up @@ -1360,7 +1359,7 @@ describe('define attrs', () => {
props: {
bar: Number
},
attrs: Object as AttrsType<ExtractPropsAndEvents<typeof Child>>,
attrs: Object as AttrsType<typeof Child>,
created() {
expectType<unknown>(this.$attrs.class)
expectType<unknown>(this.$attrs.style)
Expand Down
11 changes: 5 additions & 6 deletions packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ import {
ComponentPublicInstance,
isReservedPrefix,
IntersectionMixin,
UnwrapMixinsType
UnwrapMixinsType,
ComponentPublicInstanceConstructor
} from './componentPublicInstance'
import { warn } from './warning'
import { VNodeChild } from './vnode'
Expand Down Expand Up @@ -419,12 +420,10 @@ export type ComponentOptionsMixin = ComponentOptionsBase<

declare const AttrSymbol: unique symbol
export type AttrsType<T extends Record<string, any> = Record<string, any>> = {
[AttrSymbol]?: T
[AttrSymbol]?: T extends ComponentPublicInstanceConstructor
? InstanceType<T>['$props']
: T
}
// extract props and event types from components
export type ExtractPropsAndEvents<
T extends abstract new (...args: any) => any
> = InstanceType<T>['$props']

export type UnwrapAttrsType<
Attrs extends AttrsType,
Expand Down
3 changes: 1 addition & 2 deletions packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ export type {
ComputedOptions,
RuntimeCompilerOptions,
ComponentInjectOptions,
AttrsType,
ExtractPropsAndEvents
AttrsType
} from './componentOptions'
export type { EmitsOptions, ObjectEmitsOptions } from './componentEmits'
export type {
Expand Down

0 comments on commit 418e2d2

Please sign in to comment.