fedify icon indicating copy to clipboard operation
fedify copied to clipboard

Add `readonly` modifiers to types and interfaces for immutability by default

Open dahlia opened this issue 3 months ago • 3 comments

Summary

Fedify follows the principle of immutability by default, but currently most type and interface fields don't have readonly modifiers. Similarly, arrays are declared as T[] instead of readonly T[]. This change would make the type system better reflect Fedify's immutability principles.

Background

While this improvement has been desired for some time, it was previously blocked by backward compatibility concerns. With Fedify 2.0, we can introduce this breaking change to improve type safety and better express the library's immutability design.

Proposed Changes

  1. Add readonly modifiers to interface and type fields throughout the codebase
  2. Replace T[] with readonly T[] for array types where appropriate
  3. Ensure this change is consistently applied across all packages in the monorepo

Impact

  • Breaking change: This will be a breaking change for users who rely on mutating Fedify objects
  • Type safety: Improved compile-time guarantees about immutability
  • Design consistency: Types will better reflect Fedify's immutability-first design principles

Scope

This change should be applied to:

  • Core Fedify types in packages/fedify/
  • Integration packages (@fedify/hono, @fedify/express, etc.)
  • Database adapter packages
  • Any other relevant type definitions across the monorepo

Target

  • Target branch: next (as this is a breaking change for Fedify 2.0)

Acceptance Criteria

  • [ ] All relevant interface and type fields have appropriate readonly modifiers
  • [ ] Array types are changed from T[] to readonly T[] where appropriate
  • [ ] All packages in the monorepo are updated consistently
  • [ ] Tests pass after the changes
  • [ ] No unintentional breaking changes beyond the intended immutability enforcement

dahlia avatar Sep 10 '25 08:09 dahlia

i wanna try this!

beberiche avatar Sep 11 '25 03:09 beberiche

@beberiche This issue has been assigned for over two weeks without updates. Please provide a status update, or unassign yourself if you're unable to continue working on it.

github-actions[bot] avatar Oct 09 '25 09:10 github-actions[bot]

@beberiche This issue has been assigned for over two weeks without updates. Please provide a status update, or unassign yourself if you're unable to continue working on it.

github-actions[bot] avatar Oct 24 '25 01:10 github-actions[bot]