---
title: "fast-xml-parser: TypeScript types for CommonJS | VulCode"
description: "In fast-xml-parser we added the endIndex field to the CommonJS type declaration. Without it, code loading the package with require() got a type error."
url: "https://vulcode.com/en/opensource/contributions/fast-xml-parser"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

NaturalIntelligence/fast-xml-parser

# fast-xml-parser

A fast XML parser, validator and builder for JavaScript that works without C or C++ based libraries and without callbacks.

[See the repository](https://github.com/NaturalIntelligence/fast-xml-parser) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: JavaScript
- **GitHub stars**: 3,143
- **Merged changes**: 1
- **Project site**: [naturalintelligence.github.io](https://naturalintelligence.github.io/fast-xml-parser/)

## What we changed

The CommonJS type declaration (lib/fxp.d.cts) gained the endIndex field on XMLMetaData that the main declaration in src/fxp.d.ts already had.

### What this work shows

- TypeScript type declarations

- Dual ESM and CommonJS npm packages

What was broken

### endIndex was missing for CommonJS

The XMLMetaData interface in src/fxp.d.ts had an endIndex field, the position where an XML node ends in the input, but lib/fxp.d.cts did not. CommonJS code that read endIndex got a type error.

How we fixed it

### The same field in both declarations

We added endIndex to lib/fxp.d.cts with the same type and doc comment as in src/fxp.d.ts, so both variants of the package describe node metadata the same way.

[#896](https://github.com/NaturalIntelligence/fast-xml-parser/pull/896)

## Merged change

1 27 October 2026

- [01 #896Merged 27 October 2026 fix: add endIndex to the CommonJS XMLMetaData declaration](https://github.com/NaturalIntelligence/fast-xml-parser/pull/896)

## What it taught us

We make sure an npm package shipped for both ESM and CommonJS has matching type declarations in both variants, because code that loads it with require() relies on the .d.cts file.

[More about this technology: TypeScript, React and Node](https://vulcode.com/en/technologies/typescript-react-and-node)

## Other projects we write code for

- [**Material UI** JavaScript · 99,391 stars A React component library that implements Google's Material Design: ready-made text fields, selects, buttons and other interface elements.](https://vulcode.com/en/opensource/contributions/material-ui)

- [**Grafana** TypeScript · 78,050 stars An open observability and data visualisation platform that shows metrics, logs and traces from Prometheus, Loki, Elasticsearch, PostgreSQL and many other sources on dashboards.](https://vulcode.com/en/opensource/contributions/grafana)

- [**Marked** TypeScript · 37,323 stars A fast Markdown parser and compiler to HTML, written in TypeScript and following CommonMark and GitHub Flavored Markdown.](https://vulcode.com/en/opensource/contributions/marked)

- [**Autoprefixer** JavaScript · 22,197 stars A PostCSS plugin that adds browser prefixes to CSS based on Can I Use data, including the -ms-grid syntax for CSS Grid layouts.](https://vulcode.com/en/opensource/contributions/autoprefixer)

- [**Lichess** TypeScript · 19,013 stars The lichess.org chess server: free, ad-free and open source, focused on real-time play. The back end is written in Scala, the interface in TypeScript.](https://vulcode.com/en/opensource/contributions/lichess)

- [**compromise** JavaScript · 12,176 stars A natural language processing library in JavaScript: it splits text into sentences and words, tags parts of speech, conjugates verbs and inflects nouns, and reads dates through a plugin. It runs in the browser and in Node.js.](https://vulcode.com/en/opensource/contributions/compromise)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
