Skip to content

DeepReadonly type #1452

@stefnotch

Description

@stefnotch

What problem does this feature solve?

Currently, readonly({}) uses the Readonly<> type. This makes all properties readonly. However, it should also affect nested properties.

any nested property accessed will be readonly as well
-- https://vue-composition-api-rfc.netlify.app/api.html#readonly

So, I suggest adding a DeepReadonly type like the one in ts-essentials and using it for the readonly({}) function. This would result in Typescript being able to catch more errors at compile time.

What does the proposed API look like?

export type DeepReadonly<T> = ...;

export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions