Repository navigation
fix: type EntityDecoderOptions.setXmlVersion's version as a number - #880
Merged
amitguptagwl merged 1 commit intoSep 29, 2026
Conversation
OrderedObjParser calls `this.entityDecoder.setXmlVersion(Number(ver) || 1.0)`, and the default decoder from @nodable/entities compares `version === 1.1`, but EntityDecoderOptions declared the parameter a string. A custom decoder written for the number it receives failed to compile, while one written to the declaration compared the number against "1.1" and never matched. The declaration, its CommonJS copy and the documented type now say number, and the typings test pins both halves: a number-taking decoder compiles, and a string-taking one does not.
Member
|
Thanks |
renovate Bot
added a commit
to cigaleapp/cigale
that referenced
this pull request
Oct 12, 2026
##### [v5.11.2](https://github.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.11.2) #### What's Changed - fix: decode Uint8Array XML input as UTF-8 by [@emme1t](https://github.com/emme1t) in [#875](NaturalIntelligence/fast-xml-parser#875) - fix: type EntityDecoderOptions.setXmlVersion's version as a number by [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) in [#880](NaturalIntelligence/fast-xml-parser#880) #### New Contributors - [@emme1t](https://github.com/emme1t) made their first contribution in [#875](NaturalIntelligence/fast-xml-parser#875) - [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) made their first contribution in [#880](NaturalIntelligence/fast-xml-parser#880) **Full Changelog**: <NaturalIntelligence/fast-xml-parser@v5.11.1...v5.11.2>
renovate Bot
added a commit
to cigaleapp/cigale
that referenced
this pull request
Oct 12, 2026
##### [v5.11.2](https://github.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.11.2) #### What's Changed - fix: decode Uint8Array XML input as UTF-8 by [@emme1t](https://github.com/emme1t) in [#875](NaturalIntelligence/fast-xml-parser#875) - fix: type EntityDecoderOptions.setXmlVersion's version as a number by [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) in [#880](NaturalIntelligence/fast-xml-parser#880) #### New Contributors - [@emme1t](https://github.com/emme1t) made their first contribution in [#875](NaturalIntelligence/fast-xml-parser#875) - [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) made their first contribution in [#880](NaturalIntelligence/fast-xml-parser#880) **Full Changelog**: <NaturalIntelligence/fast-xml-parser@v5.11.1...v5.11.2>
renovate Bot
added a commit
to cigaleapp/cigale
that referenced
this pull request
Oct 12, 2026
##### [v5.11.2](https://github.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.11.2) #### What's Changed - fix: decode Uint8Array XML input as UTF-8 by [@emme1t](https://github.com/emme1t) in [#875](NaturalIntelligence/fast-xml-parser#875) - fix: type EntityDecoderOptions.setXmlVersion's version as a number by [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) in [#880](NaturalIntelligence/fast-xml-parser#880) #### New Contributors - [@emme1t](https://github.com/emme1t) made their first contribution in [#875](NaturalIntelligence/fast-xml-parser#875) - [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) made their first contribution in [#880](NaturalIntelligence/fast-xml-parser#880) **Full Changelog**: <NaturalIntelligence/fast-xml-parser@v5.11.1...v5.11.2>
renovate Bot
added a commit
to cigaleapp/cigale
that referenced
this pull request
Oct 12, 2026
##### [v5.11.2](https://github.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.11.2) #### What's Changed - fix: decode Uint8Array XML input as UTF-8 by [@emme1t](https://github.com/emme1t) in [#875](NaturalIntelligence/fast-xml-parser#875) - fix: type EntityDecoderOptions.setXmlVersion's version as a number by [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) in [#880](NaturalIntelligence/fast-xml-parser#880) #### New Contributors - [@emme1t](https://github.com/emme1t) made their first contribution in [#875](NaturalIntelligence/fast-xml-parser#875) - [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) made their first contribution in [#880](NaturalIntelligence/fast-xml-parser#880) **Full Changelog**: <NaturalIntelligence/fast-xml-parser@v5.11.1...v5.11.2>
renovate Bot
added a commit
to cigaleapp/cigale
that referenced
this pull request
Oct 12, 2026
##### [v5.11.2](https://github.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.11.2) #### What's Changed - fix: decode Uint8Array XML input as UTF-8 by [@emme1t](https://github.com/emme1t) in [#875](NaturalIntelligence/fast-xml-parser#875) - fix: type EntityDecoderOptions.setXmlVersion's version as a number by [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) in [#880](NaturalIntelligence/fast-xml-parser#880) #### New Contributors - [@emme1t](https://github.com/emme1t) made their first contribution in [#875](NaturalIntelligence/fast-xml-parser#875) - [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) made their first contribution in [#880](NaturalIntelligence/fast-xml-parser#880) **Full Changelog**: <NaturalIntelligence/fast-xml-parser@v5.11.1...v5.11.2>
renovate Bot
added a commit
to cigaleapp/cigale
that referenced
this pull request
Oct 12, 2026
##### [v5.11.2](https://github.com/NaturalIntelligence/fast-xml-parser/releases/tag/v5.11.2) #### What's Changed - fix: decode Uint8Array XML input as UTF-8 by [@emme1t](https://github.com/emme1t) in [#875](NaturalIntelligence/fast-xml-parser#875) - fix: type EntityDecoderOptions.setXmlVersion's version as a number by [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) in [#880](NaturalIntelligence/fast-xml-parser#880) #### New Contributors - [@emme1t](https://github.com/emme1t) made their first contribution in [#875](NaturalIntelligence/fast-xml-parser#875) - [@YevheniiKotyrlo](https://github.com/YevheniiKotyrlo) made their first contribution in [#880](NaturalIntelligence/fast-xml-parser#880) **Full Changelog**: <NaturalIntelligence/fast-xml-parser@v5.11.1...v5.11.2>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose / Goal
EntityDecoderOptions.setXmlVersionis declared as taking a string, but the parser passes the number it read off<?xml version?>:No issue was raised for this, so here is input / expected / actual, for anyone passing their own
entityDecoder(supported since 5.7.0):Input
Actual (5.11.1):
TS2322: Type '(version: number) => void' is not assignable to type '(version: string) => void'.A decoder written to the declaration instead compiles, but at runtime receives1.1as a number, so aversion === '1.1'check never matches.Expected: the number-typed decoder compiles.
@nodable/entities, the default decoder, handles the version as a number too (this._ncrXmlVersion = version === 1.1 ? 1.1 : 1.0).The declaration, its CommonJS copy and the documented type now say
number.Type
Tests
spec/typings/typings-test.tsgains two cases: a decoder whosesetXmlVersiontakes a number compiles, and one taking a string does not (((version: string) => void) extends EntityDecoderOptions['setXmlVersion']must befalse). I compiled the test against four declarations:setXmlVersionparameternpm run test-typesnumber(this PR)string(5.11.1)anystring | numberVerification
npm run test-typespasses ·jasmine332 specs, 0 failures, 2 pending (same asmaster) ·eslintoutput identical tomaster(the diff has no.js) ·git diff --checkclean.node benchmark/XmlParser.mjsnot run: the diff changes declarations, the typings test and docs, so the parser executes the same code before and after.No existing issue or PR covers this. I searched the tracker for
setXmlVersion,EntityDecoderOptionsandentityDecoder, and the only hits were #819, #825 and #829, about which entities are decoded by default.Related
nodable/val-parsers#6 fixes the matching declaration in
@nodable/entities, whereEntityDecoderis declared as a default export with nosetXmlVersionat all.Base
Cut from
bb2ec6c(master), merges cleanly.