Repository navigation
fix(entities): declare EntityDecoder as the named export it is, with setXmlVersion - #6
Merged
amitguptagwl merged 1 commit intoSep 29, 2026
Conversation
…setXmlVersion
index.js exports EntityDecoder by name (`export { default as EntityDecoder }`),
but index.d.ts declares it as the default export. The named import a consumer
needs therefore fails to type-check (TS2724), while the default import the
declaration advertises throws when the module links, because there is no
'default' export.
The declaration also omits setXmlVersion, which docs/EntityDecoder.md
documents and fast-xml-parser calls once it has read `<?xml version?>`.
The docs example that used the default import now uses the named one.
1 of 3 tasks
Contributor
|
Thanks |
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.
Problem
index.d.tsdeclaresEntityDecoderas the default export, butindex.jsexports it by name:In TypeScript the import that runs does not compile, and the import that compiles does not run. This holds for every consumer, measured against the published
3.0.0(latest), whosesrc/index.d.tsis the same blob asmain(c513cf5):tsc --strict --module nodenextimport { EntityDecoder } from '@nodable/entities'TS2724: … has no exported member named 'EntityDecoder'. Did you mean 'EntityEncoder'?import EntityDecoder from '@nodable/entities'SyntaxError: The requested module … does not provide an export named 'default'The class also omits
setXmlVersion(version), whichdocs/EntityDecoder.mddocuments and fast-xml-parser calls once it reads<?xml version?>, sodecoder.setXmlVersion(1.1)isTS2339.#4 and #1 reported the export half and were closed with "Can you please confirm?". This is that confirmation: the declaration
3.0.0ships is unchanged.Solution
export class EntityDecoder, matching the named exportindex.jsprovides.setXmlVersion(version: number): void, matching the runtime's@param {1.0|1.1|number} versionand theNumber(ver) || 1.0fast-xml-parser passes.docs/EntityDecoder.mdused the default import; it now uses the named one, like every other example there.Tests
The package has no type tests, so the evidence is a probe compiled against
src/index.d.tsand run againstsrc/index.js:Before:
TS2724on the import (andTS2339onsetXmlVersionwith the default import). After:tscexits 0 and Node prints"first\nsecond".Verification
jest3 suites, 246 passed · the probe above compiles and runs · declarations and docs only, no runtime change.Searched the tracker for
EntityDecoder,default export,setXmlVersionandindex.d.ts: #1 and #4 are the only hits, both closed.Base
Cut from
d2070d7(main), merges cleanly.