Skip to content

TS[5.1] Use as const for Immutable Objects #220

@MaryamAdnan3

Description

@MaryamAdnan3

Problem:

Currently, enums allow modification at runtime, which is unsafe.

Proposed Solution:

Convert enums to immutable constant objects using as const.

TypeScript Version Required: 5.1+

Example Fix (retryConfiguration.ts):

export const RequestRetryOption = {
  Enable: "enable",
  Disable: "disable",
  Default: "default",
} as const;

Expected Benefits:

  • Prevents accidental modification of enum values at runtime.
  • Improves type safety when working with predefined options.

Applicable Files:

  • retryConfiguration.ts
  • loggingOptions.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions