From 391f1a17e5697bf1fd9d57fa1b2a482aeab1b1a0 Mon Sep 17 00:00:00 2001 From: Katashin Date: Mon, 17 Feb 2020 10:07:54 +0100 Subject: [PATCH] fix: avoid accessing undeclared instance fields on type level (#189) * fix: avoid accessing undeclared instance fields on type level * fix: inherit vue constructor type for constructor proxy fix #187 fix #185 --- src/component/component.ts | 10 +++++----- test/types/createComponent.spec.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/component/component.ts b/src/component/component.ts index 71148d52..e9b36b6a 100644 --- a/src/component/component.ts +++ b/src/component/component.ts @@ -22,8 +22,8 @@ export type ComponentRenderProxy

= { S; // for Vetur and TSX support -type VueConstructorProxy = { - new (): ComponentRenderProxy< +type VueConstructorProxy = VueConstructor & { + new (...args: any[]): ComponentRenderProxy< ExtractPropTypes, UnwrapRef, ExtractPropTypes @@ -65,15 +65,15 @@ interface ComponentOptionsWithProps< setup?: SetupFunction; } -interface ComponentOptionsWithoutProps { +interface ComponentOptionsWithoutProps { props?: undefined; setup?: SetupFunction; } // overload 1: object format with no props export function createComponent( - options: ComponentOptionsWithoutProps -): VueProxy; + options: ComponentOptionsWithoutProps +): VueProxy; // overload 2: object format with object props declaration // see `ExtractPropTypes` in ./componentProps.ts export function createComponent< diff --git a/test/types/createComponent.spec.ts b/test/types/createComponent.spec.ts index 1a0439bb..c188467d 100644 --- a/test/types/createComponent.spec.ts +++ b/test/types/createComponent.spec.ts @@ -89,7 +89,7 @@ describe('createComponent', () => { const App = createComponent({ setup(props, ctx) { isTypeEqual(true); - isTypeEqual(true); + isTypeEqual(true); return () => null; }, });