Skip to main content

Shared Types

Shared TypeScript type definitions and interfaces used across the Substrate monorepo.

For detailed usage documentation, see the Shared Types documentation on the docs site.

Contributing

Prerequisites

  • Node.js 20+ and Yarn
  • Strong understanding of TypeScript and type systems

Commands

# Build the package
nx build shared-types

# Run tests
nx test shared-types

# Run type checking
nx typecheck shared-types

# Lint the package
nx lint shared-types

Project Structure

packages/shared-types/
├── src/
│ ├── lib/
│ │ ├── core.ts # Core type definitions
│ │ └── core.type-spec.ts # Compile-time type verification
│ └── index.ts # Package exports
├── docs/ # Documentation (built to docs site)
└── README.md # This file

Environment Variables

No environment variables required for this package.

Type Organization

Types are organized by domain:

  • Database types - Prisma ORM compatible types
  • GraphQL types - API request/response types
  • Authentication types - User and session types
  • Utility types - Common type helpers

Adding New Types

  1. Create or edit a file in src/ for the appropriate domain
  2. Define your types/interfaces
  3. Export from src/index.ts
  4. Run nx build shared-types to compile
  5. Update documentation as needed

Type Safety

This package ensures type consistency across:

  • Database models (Prisma)
  • GraphQL schemas
  • Application code (React components and utilities)

When adding types, ensure they are compatible with existing related types in other packages.