Skip to content

VersionOptions

reference
1 min readUpdated

Kind: Interface

Source: packages/common/interfaces/version-options.interface.ts

Part of: Common

VersionOptions defines the version configuration used by components that need to target or describe a specific API or application version. It provides a single version property typed as VersionValue, ensuring version values remain consistent across the system.

Properties

PropertyType
versionVersionValue

Diagram

mermaid
graph LR
  A[Consumer Configuration] --> B[VersionOptions]
  B --> C[version: VersionValue]
  C --> D[Version-Aware Component]

Usage

ts
import type { VersionOptions } from '@package/common';

const options: VersionOptions = {
  version: 'v1',
};

function configureVersion(options: VersionOptions) {
  console.log(`Using version: ${options.version}`);
}

configureVersion(options);

AI Coding Instructions

  • Provide a valid VersionValue when constructing VersionOptions; do not use arbitrary strings unless they are supported by that type.
  • Use VersionOptions for function parameters and configuration objects that require version-specific behavior.
  • Keep version handling centralized through this interface rather than introducing duplicate version field definitions.
  • Import VersionOptions as a type-only import when it is used exclusively for TypeScript type checking.

How it works

VersionOptions is a public TypeScript interface for attaching an optional API version to a controller. It declares one property, version?: VersionValue. packages/common/interfaces/version-options.interface.ts:21-32

Was this page helpful?

Download as PDF
VersionOptions — NestJS head-to-head