Function: definePlan()
definePlan<
Config
,Name
,Output
,Init
>(plan
):LexicalPlan
<Config
,Name
,Output
,Init
>
Define a LexicalPlan from the given object literal. TypeScript will infer Config and Name in most cases, but you may want to use safeCast for config if there are default fields or varying types.
Type Parameters
• Config extends PlanConfigBase
• Name extends string
• Output
• Init
Parameters
• plan: LexicalPlan
<Config
, Name
, Output
, Init
>
The LexicalPlan
Returns
LexicalPlan
<Config
, Name
, Output
, Init
>
The unmodified plan argument (this is only an inference helper)
Examples
export const MyPlan = definePlan({
// Plan names must be unique in an editor
name: "my",
nodes: [MyNode],
});
export interface ConfigurableConfig {
optional?: string;
required: number;
}
export const ConfigurablePlan = definePlan({
name: "configurable",
// The Plan's config must satisfy the full config type,
// but using the Plan as a dependency never requires
// configuration and any partial of the config can be specified
config: safeCast<ConfigurableConfig>({ required: 1 }),
});