NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.45k stars 296 forks source link

Incorrect return type for `tagValueProcessor` and `attributeValueProcessor` in XmlBuilderOptions #581

Closed monholm closed 2 months ago

monholm commented 1 year ago

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?

github-actions[bot] commented 1 year ago

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.