Skip to main content

API Overview

TypeScript API Pro provides a rich set of type utilities organized into four main modules:

đŸ“Ļ Module Structure​

typescript-api-pro/
├── object/ # Object type utilities
├── array/ # Array type utilities
├── map/ # Map type utilities
└── set/ # Set type utilities

🔧 Core Types​

Basic Types​

Object Operations​

Dependency Relationships​

Array Operations​

Map Operations​

Set Operations​

đŸŽ¯ Use Cases​

Type-Safe Configuration Objects​

import type { MutuallyWithObject, RequiredDependency } from 'typescript-api-pro';

interface DatabaseConfig {
host?: string;
port?: number;
ssl?: boolean;
}

// Ensure host and port exist together or not at all
type SafeDatabaseConfig = RequiredDependency<DatabaseConfig, 'host', 'port'>;

Mutually Exclusive Options​

import type { MutuallyWithObject } from 'typescript-api-pro';

interface AuthOptions {
token: string;
username: string;
apiKey: string;
}

// Only one authentication method can be selected
type AuthMethod = MutuallyWithObject<AuthOptions>;

Collection Type Conversion​

import type { ArrayToSet, MapToObject, SetToArray } from 'typescript-api-pro';

// Array to Set (automatic deduplication)
type UniqueColors = ArrayToSet<['red', 'blue', 'red', 'green']>; // Set<'red' | 'blue' | 'green'>

// Map to object
type ConfigObject = MapToObject<Map<'host' | 'port', string>>; // { host: string; port: string; }

📖 Learn More​

Choose a specific type category to learn more details and usage examples: