Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

DeepReadonly

DeepReadonly<T> = T extends Entity ? T : T extends Vector3 ? ReadonlyVector3 : T extends Quaternion ? ReadonlyQuaternion : T extends Vector2 ? ReadonlyVector2 : T extends (…args) => unknown ? T : T extends ReadonlyMap<infer Key, infer Value> ? ReadonlyMap<Key, DeepReadonly<Value>> : T extends ReadonlySet<infer Value> ? ReadonlySet<DeepReadonly<Value>> : T extends readonly …[] ? readonly DeepReadonly<…>[] : T extends object ? { readonly [Key in keyof (...)]: DeepReadonly<(...)> } : T

T with no field a reader can change, at any depth, and three’s vectors and quaternions as their read-only views. A mapped type leaves a class’s own methods callable, so another class’s methods that write, such as a Color’s set, stay callable: the type does not cover them.

Type Parameter
T