Skip to content

Commit 391f1a1

Browse files
ktsnpikax
authored andcommitted
fix: avoid accessing undeclared instance fields on type level (vuejs#189)
* fix: avoid accessing undeclared instance fields on type level * fix: inherit vue constructor type for constructor proxy fix vuejs#187 fix vuejs#185
1 parent af1dd40 commit 391f1a1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/component/component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export type ComponentRenderProxy<P = {}, S = {}, PublicProps = P> = {
2222
S;
2323

2424
// for Vetur and TSX support
25-
type VueConstructorProxy<PropsOptions, RawBindings> = {
26-
new (): ComponentRenderProxy<
25+
type VueConstructorProxy<PropsOptions, RawBindings> = VueConstructor & {
26+
new (...args: any[]): ComponentRenderProxy<
2727
ExtractPropTypes<PropsOptions>,
2828
UnwrapRef<RawBindings>,
2929
ExtractPropTypes<PropsOptions, false>
@@ -65,15 +65,15 @@ interface ComponentOptionsWithProps<
6565
setup?: SetupFunction<Props, RawBindings>;
6666
}
6767

68-
interface ComponentOptionsWithoutProps<Props = never, RawBindings = Data> {
68+
interface ComponentOptionsWithoutProps<Props = unknown, RawBindings = Data> {
6969
props?: undefined;
7070
setup?: SetupFunction<Props, RawBindings>;
7171
}
7272

7373
// overload 1: object format with no props
7474
export function createComponent<RawBindings>(
75-
options: ComponentOptionsWithoutProps<never, RawBindings>
76-
): VueProxy<never, RawBindings>;
75+
options: ComponentOptionsWithoutProps<unknown, RawBindings>
76+
): VueProxy<unknown, RawBindings>;
7777
// overload 2: object format with object props declaration
7878
// see `ExtractPropTypes` in ./componentProps.ts
7979
export function createComponent<

test/types/createComponent.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('createComponent', () => {
8989
const App = createComponent({
9090
setup(props, ctx) {
9191
isTypeEqual<SetupContext, typeof ctx>(true);
92-
isTypeEqual<never, typeof props>(true);
92+
isTypeEqual<unknown, typeof props>(true);
9393
return () => null;
9494
},
9595
});

0 commit comments

Comments
 (0)