@orsetra/shared-types
v1.0.3
Published
Shared TypeScript types for Orsetra platform
Readme
@orsetra/shared-types
Shared TypeScript type definitions for Orsetra platform.
Installation
npm install @orsetra/shared-types
# or
pnpm add @orsetra/shared-types
# or
yarn add @orsetra/shared-typesUsage
import type { User, ApiResponse, PaginatedData } from '@orsetra/shared-types'
// Use the types in your code
const user: User = {
id: '123',
email: '[email protected]',
name: 'John Doe',
}
const response: ApiResponse<User> = {
success: true,
data: user,
}Available Types
Common Types
- User - User entity type
- ApiResponse - Generic API response wrapper
- PaginatedData - Paginated data structure
- ErrorResponse - Error response structure
Import Specific Types
import type { User } from '@orsetra/shared-types/types/common'Type Safety
All types are strictly typed and provide full IntelliSense support in modern IDEs.
import type { ApiResponse } from '@orsetra/shared-types'
function handleResponse(response: ApiResponse<User>) {
if (response.success) {
// TypeScript knows response.data is User
console.log(response.data.email)
} else {
// TypeScript knows response.error exists
console.error(response.error)
}
}Extending Types
You can extend the shared types in your own projects:
import type { User } from '@orsetra/shared-types'
interface ExtendedUser extends User {
customField: string
}License
MIT