histoire
Version:
A fast story book powered by Vite
36 lines • 1.77 kB
TypeScript
import type { ASTNode } from 'magicast';
import type { ConfigPathAnalysis, JsonValue, ObjectNode, ParsedConfig, PathToken, PropertyNode } from './types.js';
/** A decoded literal, or a source-specific reason to refuse it. */
export interface StaticValue {
/** JSON value when all nodes are static. */
value?: JsonValue;
/** Refused expression. */
issue?: ConfigPathAnalysis;
}
/** A path target or the first missing property where insertion can begin. */
export interface LocatedPath {
/** Existing expression at this path. */
node?: ASTNode;
/** Its containing object or array. */
parent?: ObjectNode | Extract<ASTNode, {
type: 'ArrayExpression';
}>;
/** Existing object property, when applicable. */
property?: PropertyNode;
/** Remaining tokens starting with the first missing property. */
missing?: PathToken[];
/** Refusal preventing traversal. */
issue?: ConfigPathAnalysis;
}
/** Reads ordinary property names without evaluating computed keys. */
export declare function propertyName(property: ObjectNode['properties'][number]): string | undefined;
/** Finds a stable property, rejecting duplicates and later unknown overrides. */
export declare function findProperty(object: ObjectNode, key: string): {
property?: PropertyNode;
issue?: ConfigPathAnalysis;
};
/** Decodes literals recursively; functions, spreads, imports and calls never run. */
export declare function staticValue(parsed: ParsedConfig, input: ASTNode, followed?: boolean): StaticValue;
/** Traverses only literal objects and arrays selected by a stable preset id. */
export declare function locateConfigPath(parsed: ParsedConfig, object: ObjectNode, tokens: PathToken[]): LocatedPath;
//# sourceMappingURL=walk.d.ts.map