hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
29 lines • 1.3 kB
TypeScript
/**
* This module provides function to implement proxy-based object, functions, and
* classes (they are functions). They receive an initializer function that it's
* not used until someone interacts with the lazy element.
*
* This functions can also be used like a lazy `require`, creating a proxy that
* doesn't require the module until needed.
*
* The disadvantage of using this technique is that the type information is
* lost wrt `import`, as `require` returns an `any. If done with enough care,
* this can be manually fixed.
*
* TypeScript doesn't emit `require` calls for modules that are imported only
* because of their types. So if one uses lazyObject or lazyFunction along with
* a normal ESM import you can pass the module's type to this function.
*
* An example of this can be:
*
* import findUpT from "find-up";
* export const findUp = lazyFunction<typeof findUpT>(() => require("find-up"));
*
* You can also use it with named exports:
*
* import { EthT } from "web3x/eth";
* const Eth = lazyFunction<typeof EthT>(() => require("web3x/eth").Eth);
*/
export declare function lazyObject<T extends object>(objectCreator: () => T): T;
export declare function lazyFunction<T extends Function>(functionCreator: () => T): T;
//# sourceMappingURL=lazy.d.ts.map