Skip to content

Commit 6d0acae

Browse files
committed
wip [skip ci]
1 parent b78953f commit 6d0acae

File tree

7 files changed

+419
-132
lines changed

7 files changed

+419
-132
lines changed

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

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,8 +1901,61 @@ declare const ErrorMessage: {
19011901
__isFragment?: never
19021902
__isTeleport?: never
19031903
__isSuspense?: never
1904-
} & vue.ComponentOptionsBase &
1905-
vue.PublicProps &
1904+
} & vue.ComponentOptionsBase<
1905+
Readonly<
1906+
vue.ExtractPropTypes<{
1907+
as: {
1908+
type: StringConstructor
1909+
default: any
1910+
}
1911+
name: {
1912+
type: StringConstructor
1913+
required: true
1914+
}
1915+
}>
1916+
>,
1917+
() =>
1918+
| VNode<
1919+
vue.RendererNode,
1920+
vue.RendererElement,
1921+
{
1922+
[key: string]: any
1923+
}
1924+
>
1925+
| vue.Slot<any>
1926+
| VNode<
1927+
vue.RendererNode,
1928+
vue.RendererElement,
1929+
{
1930+
[key: string]: any
1931+
}
1932+
>[]
1933+
| {
1934+
default: () => VNode<
1935+
vue.RendererNode,
1936+
vue.RendererElement,
1937+
{
1938+
[key: string]: any
1939+
}
1940+
>[]
1941+
},
1942+
unknown,
1943+
{},
1944+
{},
1945+
{},
1946+
{},
1947+
{},
1948+
string,
1949+
{
1950+
as: string
1951+
},
1952+
{},
1953+
string,
1954+
{}
1955+
> &
1956+
vue.VNodeProps &
1957+
vue.AllowedComponentProps &
1958+
vue.ComponentCustomProps &
19061959
(new () => {
19071960
$slots: {
19081961
default: (arg: ErrorMessageSlotProps) => VNode[]

packages/runtime-core/__tests__/apiOptions.spec.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import type { Mock } from 'vitest'
55
import {
6-
type ComponentOptionsBase,
6+
type ComponentOptions,
77
type TestElement,
88
computed,
99
createApp,
@@ -1415,9 +1415,8 @@ describe('api: options', () => {
14151415
})
14161416

14171417
test('computed with setter and no getter', () => {
1418-
const Comp: ComponentOptionsBase = {
1418+
const Comp: ComponentOptions = {
14191419
computed: {
1420-
// @ts-expect-error
14211420
foo: {
14221421
set() {},
14231422
},
@@ -1432,9 +1431,8 @@ describe('api: options', () => {
14321431

14331432
test('assigning to computed with no setter', () => {
14341433
let instance: any
1435-
const Comp: ComponentOptionsBase = {
1434+
const Comp: ComponentOptions = {
14361435
computed: {
1437-
// @ts-expect-error
14381436
foo: {
14391437
get() {},
14401438
},
@@ -1485,9 +1483,8 @@ describe('api: options', () => {
14851483
})
14861484

14871485
test('methods property is not a function', () => {
1488-
const Comp: ComponentOptionsBase = {
1486+
const Comp: ComponentOptions = {
14891487
methods: {
1490-
// @ts-expect-error
14911488
foo: 1,
14921489
},
14931490
render() {},

packages/runtime-core/src/apiDefineComponent.ts

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import type {
1717
import type {
1818
ComponentInjectOptions,
1919
ComponentOptions,
20-
ComponentOptionsBase,
2120
ComponentProvideOptions,
21+
ComponentStaticOptions,
2222
ComputedOptions,
2323
MethodOptions,
2424
ObjectInjectOptions,
@@ -179,23 +179,7 @@ type InferComponentOptions<T> = T &
179179
TypeRefs & {},
180180
TypeEl & Element
181181
>
182-
} & Omit<
183-
ComponentOptionsBase,
184-
| 'props'
185-
| 'emits'
186-
| 'components'
187-
| 'directives'
188-
| 'slots'
189-
| 'expose'
190-
| 'computed'
191-
| 'methods'
192-
| 'provide'
193-
| 'inject'
194-
| 'mixins'
195-
| 'extends'
196-
| 'setup'
197-
| 'data'
198-
>
182+
} & ComponentStaticOptions
199183
: {})
200184

201185
export type DefineSetupFnComponent<
@@ -378,23 +362,7 @@ export function defineComponent<
378362

379363
// allow any custom options
380364
[key: string]: any
381-
} & Omit<
382-
ComponentOptionsBase,
383-
| 'props'
384-
| 'emits'
385-
| 'components'
386-
| 'directives'
387-
| 'slots'
388-
| 'expose'
389-
| 'computed'
390-
| 'methods'
391-
| 'provide'
392-
| 'inject'
393-
| 'mixins'
394-
| 'extends'
395-
| 'setup'
396-
| 'data'
397-
> &
365+
} & ComponentStaticOptions &
398366
ThisType<
399367
NoInfer<InternalInstance> & {
400368
$options: typeof options

packages/runtime-core/src/apiSetupHelpers.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from './component'
1818
import type { EmitFn, EmitsOptions, ObjectEmitsOptions } from './componentEmits'
1919
import type {
20-
ComponentOptionsBase,
20+
ComponentStaticOptions,
2121
ComputedOptions,
2222
MethodOptions,
2323
} from './componentOptions'
@@ -230,19 +230,7 @@ export function defineOptions<
230230
* slots should be defined via defineSlots().
231231
*/
232232
slots?: never
233-
} & Omit<
234-
ComponentOptionsBase,
235-
| 'computed'
236-
| 'methods'
237-
| 'mixins'
238-
| 'extends'
239-
| 'data'
240-
| 'setup'
241-
| 'props'
242-
| 'emits'
243-
| 'expose'
244-
| 'slots'
245-
>,
233+
} & ComponentStaticOptions,
246234
): void {
247235
if (__DEV__) {
248236
warnRuntimeUsage(`defineOptions`)

0 commit comments

Comments
 (0)