import { AnyAsyncFunction, AnyFunction, Err, FunctionLike, GetAccessorDecl, MethodDecl, SetAccessorDecl } from "@functionless/ast"; /** * A macro (compile-time) function that converts an ArrowFunction or FunctionExpression to a {@link FunctionDecl}. * * Use this function to quickly grab the {@link FunctionDecl} (AST) representation of TypeScript syntax and * then perform interpretations of that representation. * * Valid uses include an in-line ArrowFunction or FunctionExpression: * ```ts * const decl1 = reflect((arg: string) => {}) * const decl2 = reflect(function (arg: string) {}) * ``` * * Illegal uses include references to functions or computed functions: * ```ts * const functionRef = () => {} * const decl1 = reflect(functionRef) * * function computeFunction() { * return () => "hello" * } * const decl2 = reflect(computeFunction()) * ``` * * @param func an in-line ArrowFunction or FunctionExpression. It must be in-line and cannot reference * a variable or a computed function/closure. */ export declare function reflect(func: F): FunctionLike | MethodDecl | GetAccessorDecl | SetAccessorDecl | Err | undefined; /** * Register a substitution. Any ReferenceExpr pointing to {@link from} * will be substituted with {@link to} when ReferenceExpr is resolved. */ export declare function registerSubstitution(from: any, to: any): void; /** * Resolve a value, potentially substituting it if a substitution has * been registered for the {@link from} value. If no substitution * has been registered, then the original value in the ReferenceExpr * is returned. */ export declare function resolveSubstitution(from: any): any; export interface BoundFunctionComponents { /** * The target function */ targetFunction: F; /** * The `this` argument bound to the function. */ boundThis: any; /** * The arguments bound to the function. */ boundArgs: any[]; } /** * Unbind a bound function into its components. * @param boundFunction the bound function * @returns the targetFunction, boundThis and boundArgs if this is a bound function compiled with Functionless, otherwise undefined. */ export declare function unbind(boundFunction: F): BoundFunctionComponents | undefined; /** * The components of a {@link Proxy}. */ export interface ProxyComponents { /** * The target object that the {@link Proxy} is intercepting. */ target: T; /** * The {@link ProxyHandler} interceptor handler functions. */ handler: ProxyHandler; } /** * Reverses a {@link Proxy} instance into the args that were used to created it. * * ```ts * const proxy = new Proxy({ hello: "world" }, { get: () => {} }); * * const components = reverseProxy(proxy); * components.target // { hello: "world" } * components.handler // { get: () => {} } * ``` * * @param proxy the proxy instance * @returns the {@link ProxyComponents} if this proxy can be reversed, or `undefined`. */ export declare function reverseProxy(proxy: T): ProxyComponents | undefined; export declare const deploymentOnlyModule = true; export declare const ReflectionSymbolNames: { readonly AST: "functionless:AST"; readonly BoundArgs: "functionless:BoundArgs"; readonly BoundThis: "functionless:BoundThis"; readonly Proxies: "functionless:Proxies"; readonly Reflect: "functionless:Reflect"; readonly TargetFunction: "functionless:TargetFunction"; }; export declare const ReflectionSymbols: { readonly AST: symbol; readonly BoundArgs: symbol; readonly BoundThis: symbol; readonly Proxies: symbol; readonly Reflect: symbol; readonly TargetFunction: symbol; }; /** * Validates and return the {@link FunctionLike} AST of {@link a} if it is: * 1. a `function` that has been registered with its AST form * 2. already a {@link FunctionLike} * * @param a any value * @param functionLocation string describing the location of this validation (for error message) * @returns a {@link FunctionLike} * @throws an Error if {@link a} has not been registered or failed to parse */ export declare function validateFunctionLike(a: any, functionLocation: string): FunctionLike; //# sourceMappingURL=reflect.d.ts.map