Feature Request
Type Expectation
A DeepReadonly<T> type is needed that recursively converts all properties of objects and arrays to readonly. Since this library provides "deep + strict" type manipulation, DeepReadonly is a natural extension.
Example Type
type Input = {
a: number;
b: {
c: string;
d: { e: boolean }[];
};
};
type Result = DeepReadonly<Input>;
// Expected:
// {
// readonly a: number;
// readonly b: {
// readonly c: string;
// readonly d: readonly { readonly e: boolean }[];
// };
// }
Proposed Solution
Create src/types/DeepReadonly.ts with the following rules:
- Add
readonly modifier to all properties
- Convert arrays to
readonly T[]
- Do not recurse into
Date types (existing library convention)
- Preserve branded types (do not unbrand before processing)
- Add re-export to
src/types/index.ts
Use Case
- Enforce immutability on API response objects to prevent accidental mutation
- Guarantee readonly state in Redux/Zustand store types
- Provide type definitions for the deep version of
Object.freeze
Test Requirements
All changes must include the following tests:
-
Backward Compatibility
- All existing tests must pass; the new type must not affect existing types
-
Feature Verification
- Simple object readonly conversion
- Nested object readonly conversion
- Array to readonly array
- Objects inside arrays are also readonly
- Date type preserved (not made readonly)
- Already readonly types remain unchanged (idempotency)
-
Complex Type Stability
- 3+ levels of nesting (
{ a: { b: { c: { d: number } } } })
- 2D arrays (
{ matrix: number[][] })
- Arrays inside objects inside arrays (
{ items: { tags: string[] }[] })
- Tuple types (
[string, { a: number }])
- Optional property preservation (
{ a?: number } → { readonly a?: number })
- Union types (
{ a: string | null })
- Branded types (
{ id: number & { __brand: 'ID' } })
any, never, unknown properties
How to verify:
npm run build:test && npm run test
npm run prettier
Feature Request
Type Expectation
A
DeepReadonly<T>type is needed that recursively converts all properties of objects and arrays toreadonly. Since this library provides "deep + strict" type manipulation,DeepReadonlyis a natural extension.Example Type
Proposed Solution
Create
src/types/DeepReadonly.tswith the following rules:readonlymodifier to all propertiesreadonly T[]Datetypes (existing library convention)src/types/index.tsUse Case
Object.freezeTest Requirements
All changes must include the following tests:
Backward Compatibility
Feature Verification
Complex Type Stability
{ a: { b: { c: { d: number } } } }){ matrix: number[][] }){ items: { tags: string[] }[] })[string, { a: number }]){ a?: number }→{ readonly a?: number }){ a: string | null }){ id: number & { __brand: 'ID' } })any,never,unknownpropertiesHow to verify: