messageformat
Version:
Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill
31 lines (30 loc) • 1.26 kB
TypeScript
import type { Expression, VariableRef } from '../data-model/types.ts';
import type { Context } from '../format-context.ts';
import { type MessageFallback } from '../functions/fallback.ts';
import { type MessageUnknownValue } from '../functions/unknown.ts';
import type { MessageValue } from '../message-value.ts';
/**
* Declarations aren't resolved until they're requierd,
* and their resolution order matters for variable resolution.
* This internal class is used to store any required data,
* and to allow for `instanceof` detection.
*
* @internal
*/
export declare class UnresolvedExpression {
expression: Expression;
scope: Record<string, unknown> | undefined;
constructor(expression: Expression, scope?: Record<string, unknown>);
}
/**
* Get the raw value of a variable.
* Resolves declarations as necessary
*
* @internal
* @returns `unknown` or `any` for input values;
* `MessageValue` for `.input` and `.local` declaration values.
*/
export declare function lookupVariableRef(ctx: Context, { name }: VariableRef): unknown;
export declare function resolveVariableRef<T extends string, P extends string>(ctx: Context<T, P>, ref: VariableRef): MessageFallback | MessageUnknownValue | (MessageValue<T, P> & {
source: string;
});