Skip to content

Incorrect return type for tagValueProcessor and attributeValueProcessor in XmlBuilderOptions #581

@monholm

Description

@monholm
  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?

Description

Both tagValueProcessor and attributeValueProcessor are declared as returning a string, but the function should allow returning the value as is (which is also the default).

Code

const xmlBuilder = new XMLBuilder({tagValueProcessor: (name, value) => value});

Output

Type '(name: string, value: unknown) => unknown' is not assignable to type '(name: string, value: unknown) => string'.
  Type 'unknown' is not assignable to type 'string'.ts(2322)
fxp.d.ts(65, 3): The expected type comes from property 'tagValueProcessor' which is declared here on type 'Partial<XmlBuilderOptions>'

expected data

No typescript error.

Would you like to work on this issue?

  • Yes
  • No

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