import ts from "typescript"; import { result } from "@valbuild/core/fp"; import { JSONValue } from "@valbuild/core/patch"; export declare class ValSyntaxError { message: string; node: ts.Node; constructor(message: string, node: ts.Node); } export type ValSyntaxErrorTree = ValSyntaxError | [ValSyntaxErrorTree, ...ValSyntaxErrorTree[]]; export declare function flattenErrors(tree: ValSyntaxErrorTree): [ValSyntaxError, ...ValSyntaxError[]]; export declare function flatMapErrors(tree: ValSyntaxErrorTree, cb: (error: ValSyntaxError) => T): [T, ...T[]]; export declare function formatSyntaxError(error: ValSyntaxError, sourceFile: ts.SourceFile): string; export declare function formatSyntaxErrorTree(tree: ValSyntaxErrorTree, sourceFile: ts.SourceFile): string[]; type LiteralPropertyName = (ts.Identifier | ts.StringLiteral | ts.NumericLiteral) & { /** * The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral, * or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters. * For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1". * https://github.com/microsoft/TypeScript/blob/4b794fe1dd0d184d3f8f17e94d8187eace57c91e/src/compiler/types.ts#L2127-L2131 */ name: string; }; type LiteralPropertyAssignment = ts.PropertyAssignment & { name: LiteralPropertyName; }; /** * Validates that the expression is a JSON compatible type of expression without * validating its children. */ export declare function shallowValidateExpression(value: ts.Expression): ValSyntaxError | undefined; /** * Validates that the expression is JSON compatible. */ export declare function deepValidateExpression(value: ts.Expression): result.Result; /** * Evaluates the expression as a JSON value */ export declare function evaluateExpression(value: ts.Expression): result.Result; export declare function findObjectPropertyAssignment(value: ts.ObjectLiteralExpression, key: string): result.Result; export declare function validateInitializers(nodes: ReadonlyArray): ValSyntaxErrorTree | undefined; export {};