From 3adefd3d2f911156b126fc419542ad0b25715698 Mon Sep 17 00:00:00 2001 From: dicky Date: Sat, 23 May 2020 21:27:19 -0700 Subject: [PATCH] Update type. --- DevApp/src/dotnetify/_typings/index.ts | 11 +---------- DevApp/src/dotnetify/react/useConnect.tsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/DevApp/src/dotnetify/_typings/index.ts b/DevApp/src/dotnetify/_typings/index.ts index 3ae870fb..1aff7435 100644 --- a/DevApp/src/dotnetify/_typings/index.ts +++ b/DevApp/src/dotnetify/_typings/index.ts @@ -168,13 +168,4 @@ export interface IScopeProps { export class Scope extends React.Component {} -export const useConnect = function( - vmId: string, - component?: - | { - state: T; - props: any; - } - | any, - options?: IConnectOptions -): any {}; +export declare const useConnect: (vmId: string, component?: any, options?: IConnectOptions) => { vm: IDotnetifyVM; state: T }; diff --git a/DevApp/src/dotnetify/react/useConnect.tsx b/DevApp/src/dotnetify/react/useConnect.tsx index 59eb6771..09521961 100644 --- a/DevApp/src/dotnetify/react/useConnect.tsx +++ b/DevApp/src/dotnetify/react/useConnect.tsx @@ -19,7 +19,11 @@ import * as $ from "../libs/jquery-shim"; import dotnetify from "./dotnetify-react"; import { IDotnetifyVM, IConnectOptions } from "../_typings"; -dotnetify.react.useConnect = function(iVMId: string, iComponent?: { state: T; props: any } | any, iOptions?: IConnectOptions) { +dotnetify.react.useConnect = function( + iVMId: string, + iComponent?: { state: T; props: any } | any, + iOptions?: IConnectOptions +): { vm: IDotnetifyVM; state: T } { if (useState == null || useEffect == null) throw "Error: using React hooks requires at least v16.8."; let { state, props } = iComponent; @@ -50,6 +54,10 @@ dotnetify.react.useConnect = function(iVMId: string, iComponent?: { state: T; return { vm: vm.current, state: _state }; }; -export default function(iVMId: string, iComponent?: { state: T; props: any } | any, iOptions?: IConnectOptions) { +export default function( + iVMId: string, + iComponent?: { state: T; props: any } | any, + iOptions?: IConnectOptions +): { vm: IDotnetifyVM; state: T } { return dotnetify.react.useConnect(iVMId, iComponent, iOptions); }