Types
Shared TypeScript type definitions and interfaces
Types
The @foundrykit/types
package provides shared TypeScript type definitions and interfaces used across the FoundryKit ecosystem.
Features
- Shared types: Common type definitions used across packages
- TypeScript support: Comprehensive type definitions for better development experience
- Consistent interfaces: Standardized interfaces for common patterns
- Zero runtime: Types-only package with no runtime dependencies
Installation
pnpm add @foundrykit/types
Usage
import type { ComponentProps, VariantProps } from '@foundrykit/types'
interface ButtonProps extends ComponentProps<'button'> {
variant?: VariantProps<'primary' | 'secondary' | 'destructive'>
size?: VariantProps<'sm' | 'md' | 'lg'>
}
Available Types
Component Types
- ComponentProps - Extract props from HTML elements
- ComponentRef - Extract ref types from components
- VariantProps - Type-safe variant props for components
- SlotProps - Props for slot-based components
Form Types
- FormField - Form field configuration
- ValidationRule - Form validation rules
- FormState - Form state management
- FieldError - Form field error types
UI Types
- Theme - Theme configuration types
- ColorScheme - Color scheme definitions
- Breakpoint - Responsive breakpoint types
- Spacing - Spacing scale types
Data Types
- ApiResponse - Standard API response structure
- Pagination - Pagination configuration
- Sorting - Data sorting types
- Filtering - Data filtering types
Utility Types
- DeepPartial - Make all properties optional recursively
- RequiredKeys - Extract required keys from an object
- OptionalKeys - Extract optional keys from an object
- ValueOf - Extract value types from an object
Package Structure
The types package is organized as follows:
package.json
tsconfig.json
README.md
Type Categories
Component Types
Types for building and extending React components.
Form Types
Types for form handling and validation.
UI Types
Types for theming and styling systems.
Data Types
Types for API responses and data handling.
Utility Types
Helper types for common TypeScript patterns.
Best Practices
- Import types only: Use
import type
to ensure types are not included in the bundle - Extend interfaces: Extend provided interfaces rather than redefining them
- Use generics: Leverage generic types for flexible and reusable components
- Type safety: Use strict typing to catch errors at compile time
Integration
This package is used internally by other FoundryKit packages to ensure type consistency across the ecosystem. It's also available for use in your applications to maintain consistency with FoundryKit patterns.
Dependencies
- TypeScript 5.0+
- No runtime dependencies