diff --git a/src/index.ts b/src/index.ts index c0d219e..ed4aef3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -117,10 +117,16 @@ export const factory = function ( return function (...args: any): T { return new Proxy(new type(...args), { get(target: T, property: string) { - return async (): Promise => { + const prop = target[property as keyof T]; + + if (typeof prop !== "function") { + return prop; + } + + return async (...args: any[]): Promise => { await target.loadLibs(module); - return target[property as keyof T]; + return (target[property as keyof T] as Function)(...args); }; }, });