What it Does

Makes all propertiesĀ read-onlyĀ (immutable).

Syntax

type ReadonlyType = Readonly<OriginalType>;

Use Cases

Detailed Example

interface ApiConfig{
		apiKey: string,
    baseURL: string
}

const client: Readonly<ApiConfig> = {
		apiKey: process.env.GEMINI_API_KEY,
    baseURL: "<https://generativelanguage.googleapis.com/v1beta/openai/>"
};

client.apiKey= "adlasdalsjdwqddqwdjad"; *// āŒ Error: Cannot assign to '*apiKey*' because it is a read-only property*