Shared types

Reuse Shared TypeScript Types Across Mock APIs

Organize interfaces, aliases, and string enums in multiple project files, then import and reuse them across Mock API Studio response models.

Create reusable model files

Put shared identifiers, value objects, enums, and domain types in focused .ts files. Export every declaration another project file needs.

TypeScript
// models/common.ts
export type CustomerId = string;
export type CustomerStatus = "active" | "paused";

Import shared declarations

Use project-relative imports with exact filename casing. External package imports and executable modules are rejected because the model workspace analyzes serializable declarations only.

TypeScript
import type { CustomerId, CustomerStatus } from "./common";

export interface Customer {
  id: CustomerId;
  status: CustomerStatus;
}

Bind a concrete response

An endpoint ultimately binds to a concrete exported interface or alias. Shared types are resolved as part of validation before the definition synchronizes.

Keep the graph valid

Resolve missing exports, invalid paths, unsupported recursion, and non-serializable types before starting the local runtime.

Related questions

Can project models import npm packages?

No. Model files support project-relative type imports, not external package dependencies.

Keep exploring

Last updated September 17, 2026. Product behavior described here is verified against the current Mock API Studio runtime.