Skip to content

v8.4.1

Choose a tag to compare

@github-actions github-actions released this 13 Oct 08:20
· 10 commits to master since this release
e01029d

Changes

  • fix(file-size): 🐛 Type FileSize add and subtract as FileSize

Release details

Pull request notes

What

FileSize.add and FileSize.subtract were typed as NumberValueObject (inherited), although at runtime they return a FileSize. They are now declared as add(other: FileSize): FileSize and subtract(other: FileSize): FileSize.

Notes

  • Adding or subtracting two FileSize is a closed operation, so the return type is exact. NumberValueObject is unchanged: its arithmetic can fail on subclass invariants, so this would be a wrong promise there.
  • Implemented with clone(), so subclasses of FileSize keep their own type at runtime.
  • Breaking at type level: size.add(100) with a plain number no longer compiles. Pass new FileSize(100).
  • Docs for FileSize updated with the new signatures and the negative-result error.

Verification

yarn test, yarn build pass. Coverage stays at 100%. The arithmetic test calls FileSize.to() on the results, so it only compiles if both return FileSize.