Skip to content

Commit 374b8b1

Browse files
committed
fix: remove ExtractPropsAndEvents util
1 parent b8a0891 commit 374b8b1

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

packages/dts-test/defineComponent.test-d.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import {
1414
Slots,
1515
VNode,
1616
ImgHTMLAttributes,
17-
StyleValue,
18-
ExtractPropsAndEvents
17+
StyleValue
1918
} from 'vue'
2019
import { describe, expectType, IsUnion, test } from './utils'
2120

@@ -1360,7 +1359,7 @@ describe('define attrs', () => {
13601359
props: {
13611360
bar: Number
13621361
},
1363-
attrs: Object as AttrsType<ExtractPropsAndEvents<typeof Child>>,
1362+
attrs: Object as AttrsType<typeof Child>,
13641363
created() {
13651364
expectType<unknown>(this.$attrs.class)
13661365
expectType<unknown>(this.$attrs.style)

packages/runtime-core/src/componentOptions.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ import {
6161
ComponentPublicInstance,
6262
isReservedPrefix,
6363
IntersectionMixin,
64-
UnwrapMixinsType
64+
UnwrapMixinsType,
65+
ComponentPublicInstanceConstructor
6566
} from './componentPublicInstance'
6667
import { warn } from './warning'
6768
import { VNodeChild } from './vnode'
@@ -419,12 +420,10 @@ export type ComponentOptionsMixin = ComponentOptionsBase<
419420

420421
declare const AttrSymbol: unique symbol
421422
export type AttrsType<T extends Record<string, any> = Record<string, any>> = {
422-
[AttrSymbol]?: T
423+
[AttrSymbol]?: T extends ComponentPublicInstanceConstructor
424+
? InstanceType<T>['$props']
425+
: T
423426
}
424-
// extract props and event types from components
425-
export type ExtractPropsAndEvents<
426-
T extends abstract new (...args: any) => any
427-
> = InstanceType<T>['$props']
428427

429428
export type UnwrapAttrsType<
430429
Attrs extends AttrsType,

packages/runtime-core/src/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ export type {
247247
ComputedOptions,
248248
RuntimeCompilerOptions,
249249
ComponentInjectOptions,
250-
AttrsType,
251-
ExtractPropsAndEvents
250+
AttrsType
252251
} from './componentOptions'
253252
export type { EmitsOptions, ObjectEmitsOptions } from './componentEmits'
254253
export type {

0 commit comments

Comments
 (0)