Skip to content

CreatePlugins normalize function gets wrong input #612

Description

I just tried creating my own Plugin, but i seem to face a problem with the normalize function.
Using the MyPlugin Sample:

interface MyPluginInput {
  value: number
  multiplier?: number
}

export const myPlugin = createPlugin<MyPluginInput, number, MyPluginSettings>({
  component: MyComponent,
  normalize: (input) => ({
    value: input.value ?? 0,
    settings: { multiplier: input.multiplier ?? 1 },
  }),
  sanitize: (value) =>value,
  format: (value, settings) => (value * settings.multiplier).toFixed(2),
})

This is the typescript documentation on the normalize function

(property) Plugin<MyPluginInput, number, MyPluginSettings>.normalize?: ((input: MyPluginInput, path: string, data: Data) => {
    value: number;
    settings?: MyPluginSettings | undefined;
}) | undefined
Normalizes the input into a { value, settings } object.

but at runtime input is actualy the value (10), not an object of type MyPluginInput:

Image

is the documentation not up to date, or am i missing a setting?

If required i can provide additional information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions