import type { arkKind, PrivateDeclaration, writeMissingSubmoduleAccessMessage } from "@ark/schema"; import type { anyOrNever, BigintLiteral, Completion, ErrorMessage, NumberLiteral, writeMalformedNumericLiteralMessage } from "@ark/util"; import type { Generic } from "../../generic.ts"; import type { BranchOperator, Comparator } from "../reduce/shared.ts"; import type { writeInvalidGenericArgCountMessage } from "../shift/operand/genericArgs.ts"; import type { UnitLiteral } from "../shift/operator/default.ts"; import type { parseString } from "../string.ts"; import type { validateRange } from "./bounds.ts"; import type { validateDefault } from "./default.ts"; import type { validateDivisor } from "./divisor.ts"; import type { GenericInstantiationAst, validateGenericInstantiation } from "./generic.ts"; import type { DefAst, InferredAst, InfixExpression, PostfixExpression } from "./infer.ts"; import type { validateKeyof } from "./keyof.ts"; import type { astToString } from "./utils.ts"; export type validateAst = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst : ast extends DefAst ? ast[2] extends PrivateDeclaration ? ErrorMessage> : undefined : ast extends PostfixExpression<"[]" | "?", infer operand> ? validateAst : ast extends InfixExpression ? operator extends BranchOperator ? validateInfix : operator extends Comparator ? validateRange : operator extends "%" ? validateDivisor : operator extends "=" ? validateDefault : operator extends "#" ? validateAst : ErrorMessage>> : ast extends ["keyof", infer operand] ? validateKeyof : ast extends GenericInstantiationAst ? validateGenericInstantiation : ErrorMessage>> & { ast: ast; }; type writeUnexpectedExpressionMessage = `Failed to parse the expression resulting from ${expression}`; export declare const writePrefixedPrivateReferenceMessage: (name: name) => writePrefixedPrivateReferenceMessage; export type writePrefixedPrivateReferenceMessage = `Private type references should not include '#'. Use '${name}' instead.`; type validateInferredAst = def extends NumberLiteral ? number extends inferred ? ErrorMessage> : undefined : def extends BigintLiteral ? bigint extends inferred ? ErrorMessage> : undefined : [inferred] extends [anyOrNever] ? undefined : def extends PrivateDeclaration ? ErrorMessage> : inferred extends Generic ? ErrorMessage> : inferred extends { [arkKind]: "module"; } ? "root" extends keyof inferred ? undefined : ErrorMessage> : def extends ErrorMessage ? def : undefined; export type validateString = parseString extends infer ast ? validateAst extends infer result extends ErrorMessage ? result extends Completion ? text : result : def : never; type validateInfix = validateAst extends infer e extends ErrorMessage ? e : validateAst extends infer e extends ErrorMessage ? e : undefined; export declare const shallowOptionalMessage = "Optional definitions like 'string?' are only valid as properties in an object or tuple"; export type shallowOptionalMessage = typeof shallowOptionalMessage; export declare const shallowDefaultableMessage = "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple"; export type shallowDefaultableMessage = typeof shallowDefaultableMessage; export {};