Description
With moduleResolution set to "node16" or "nodenext" (TypeScript 5.x), the package’s published ESM types entry (package.json → exports["."].import.types → ./src/fxp.d.ts) fail to type-check because src/fxp.d.ts uses a relative import without a .js extension:
import type { Expression, ReadonlyMatcher } from './pem';
TypeScript reports TS2834 (“Relative import paths need explicit file extensions in ECMAScript imports when --moduleResolution is node16 or nodenext”).
This affects consumers that type-check dependencies (e.g. skipLibCheck: false) and pull types through fast-xml-parser as a transitive dependency (for example via AWS SDK for JavaScript v3’s @aws-sdk/xml-builder, which depends on fast-xml-parser — see aws-sdk-js-v3 v3.1014.0 changelog mentioning the xml-builder / fast-xml-parser bump).
Suggested fix (either or both):
- In
src/fxp.d.ts, use a NodeNext-valid specifier, e.g. from './pem.js' (TypeScript resolves this to pem.d.ts).
- Or point
exports["."].import.types at declaration files that already satisfy NodeNext rules (e.g. generated .d.ts with correct extensions), if you prefer not to hand-edit src/*.d.ts.
Input
TypeScript project using NodeNext resolution (minimal tsconfig.json excerpt):
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"skipLibCheck": false
}
}
Code
Any dependency path that causes the compiler to load the ESM types for the main entry, e.g.:
Then run the compiler; no application import of fast-xml-parser is required if another package’s types pull in fxp.d.ts (e.g. via @aws-sdk/xml-builder).
Alternatively, a minimal direct repro:
// Any .ts file
import type { XMLParser } from "fast-xml-parser";
type _ = XMLParser;
Output
node_modules/fast-xml-parser/src/fxp.d.ts(1,50): error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
expected data
tsc should succeed with moduleResolution: "NodeNext" and skipLibCheck: false when resolving types for fast-xml-parser@5.5.8 (and future patch releases), without requiring consumers to patch node_modules or enable skipLibCheck.
Environment: fast-xml-parser@5.5.8, TypeScript 5.9 (or any 5.x with TS2834 for extensionless relative imports in .d.ts).
Would you like to work on this issue?
Bookmark this repository for further updates. Visit SoloThought to know about recent features.
Description
With
moduleResolutionset to"node16"or"nodenext"(TypeScript 5.x), the package’s published ESM types entry (package.json→exports["."].import.types→./src/fxp.d.ts) fail to type-check becausesrc/fxp.d.tsuses a relative import without a.jsextension:TypeScript reports TS2834 (“Relative import paths need explicit file extensions in ECMAScript imports when
--moduleResolutionisnode16ornodenext”).This affects consumers that type-check dependencies (e.g.
skipLibCheck: false) and pull types throughfast-xml-parseras a transitive dependency (for example via AWS SDK for JavaScript v3’s@aws-sdk/xml-builder, which depends onfast-xml-parser— see aws-sdk-js-v3 v3.1014.0 changelog mentioning the xml-builder / fast-xml-parser bump).Suggested fix (either or both):
src/fxp.d.ts, use a NodeNext-valid specifier, e.g.from './pem.js'(TypeScript resolves this topem.d.ts).exports["."].import.typesat declaration files that already satisfy NodeNext rules (e.g. generated.d.tswith correct extensions), if you prefer not to hand-editsrc/*.d.ts.Input
TypeScript project using NodeNext resolution (minimal
tsconfig.jsonexcerpt):{ "compilerOptions": { "module": "NodeNext", "moduleResolution": "NodeNext", "strict": true, "skipLibCheck": false } }Code
Any dependency path that causes the compiler to load the ESM types for the main entry, e.g.:
Then run the compiler; no application
importoffast-xml-parseris required if another package’s types pull infxp.d.ts(e.g. via@aws-sdk/xml-builder).Alternatively, a minimal direct repro:
Output
expected data
tscshould succeed withmoduleResolution:"NodeNext"andskipLibCheck:falsewhen resolving types forfast-xml-parser@5.5.8(and future patch releases), without requiring consumers to patchnode_modulesor enableskipLibCheck.Environment:
fast-xml-parser@5.5.8, TypeScript 5.9 (or any 5.x with TS2834 for extensionless relative imports in.d.ts).Would you like to work on this issue?
Bookmark this repository for further updates. Visit SoloThought to know about recent features.