Skip to content

Latest commit

 

History

History

DeepReadonly

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

DeepReadonly

Makes all properties of a type T readonly, including nested properties.

Example

interface Todo {
  title: string;
  description: string;
  completed: boolean;
  meta: {
    name: string;
    age: number; 
  };
  tags: string[];
}

type DeepReadonlyTodo = DeepReadonly<Todo>;

// output
type DeepReadonlyTodo = {
  readonly title: string;
  readonly description: string;
  readonly completed: DeepReadonly<boolean>;
  readonly meta: DeepReadonly<{
      name: string;
      age: number;
  }>;
  readonly tags: string[];
}