import type { VmValue } from '@mirascript/mirascript'; import type { Tagged } from 'type-fest'; import type { LegacyType, TsTypeOf, TypeInfo } from './type.js'; import type { Scope } from './scope.js'; import type { Evaluator } from './main.js'; /** 表达式的标记属性 */ export declare const ExpressionTag: "\u0275exp"; /** 表示一个表达式 */ export type Expression = { /** 标记,表示求值结果的类型,"" 表示无需转换类型 */ readonly [ExpressionTag]: TypeInfo | LegacyType | ''; /** 表达式内容 */ readonly source: ExpressionSource; }; /** 编译后的表达式 */ export type CompiledExpression = Expression & ExpressionFunction; /** 包装一个 {@link ExpressionFunction} */ export declare function CompiledExpression>>(fn: F, source: string, returnType: S): F & Expression>; /** 包装一个 {@link ExpressionFunction} */ export declare function CompiledExpression>(fn: F, source: string, returnType?: TypeInfo | LegacyType | ''): F & Expression; /** 表示一个表达式内容 */ export type ExpressionSource = Tagged; /** 表示表达式或值 */ export type ExpressionOrValue = Expression | T; /** 创建一个指定类型的表达式 */ export declare function Expression(source: string | Expression>, returnType: S): Expression>; /** 创建一个不转换结果类型的表达式 */ export declare function Expression(source: string | Expression): Expression; /** 检查是否为表达式 */ export declare function isExpression(value: unknown): value is Expression | CompiledExpression; /** 表示一个表达式求值的结果 */ export type ExpressionResult = T extends Expression ? R : T; /** 表示一个含表达式对象求值的结果 */ export type ExpressionResultObject = { [K in keyof T]: ExpressionResult; }; /** * 表示一个具有类似表达式功能的 JS 函数 */ export type ExpressionFunction = ( /** 当前作用域 */ scope: Scope, /** 当前求值器 */ evaluator: Evaluator) => T | null; //# sourceMappingURL=expression.d.ts.map