kpdecker / jsdiff

A javascript text differencing implementation.
BSD 3-Clause "New" or "Revised" License
7.75k stars 491 forks source link

Always set `added` and `removed` to `true` or `false`, rather than leaving them unset or explicitly using `undefined` #455

Closed ExplodingCabbage closed 7 months ago

ExplodingCabbage commented 7 months ago

Resolves https://github.com/kpdecker/jsdiff/issues/233. I figure this makes the types returned by the library a bit simpler (added and removed can simply be considered always-present booleans rather than being boolean-or-undefined-or-maybe-omitted-entirely like they are now) which in turn makes it easier for someone to make sense of the values we returned, especially if they're not intimately familiar with jsdiff but reading code that uses jsdiff in an edit that shows them type definitions.

(Obviously, actually having up-to-date type definitions is a further prerequisite for this change to be useful - hence I'd like to do https://github.com/kpdecker/jsdiff/issues/303, too, for the 6.0.0 release.)