fix(types): restore DefineComponent argument order

This is necessary for compatibility w/ tsc-generated component types
using DefineComponent.

revert #5416
reopen #3796
fix #5967
This commit is contained in:
Evan You
2022-05-21 00:53:46 +08:00
parent 583b625987
commit 8071ef47b5
5 changed files with 88 additions and 210 deletions

View File

@@ -264,18 +264,6 @@ describe('with object props', () => {
expectType<Component>(MyComponent)
expectType<typeof props>(MyComponent.props)
// @ts-expect-error it should be an object and not any
expectError<[]>(MyComponent.props)
expectType<() => {}>(MyComponent.provide)
// @ts-expect-error
expectError<[]>(MyComponent.provide)
expectType<() => null>(MyComponent.render)
expectType<Function | undefined>(defineComponent({}).render)
// Test TSX
expectType<JSX.Element>(
<MyComponent
@@ -1175,3 +1163,24 @@ export default {
}
})
}
// code generated by tsc / vue-tsc, make sure this continues to work
// so we don't accidentally change the args order of DefineComponent
declare const MyButton: import('vue').DefineComponent<
{},
() => JSX.Element,
{},
{},
{},
import('vue').ComponentOptionsMixin,
import('vue').ComponentOptionsMixin,
import('vue').EmitsOptions,
string,
import('vue').VNodeProps &
import('vue').AllowedComponentProps &
import('vue').ComponentCustomProps,
Readonly<import('vue').ExtractPropTypes<{}>>,
{}
>
;<MyButton class="x" />