Type Definitions
WSX provides comprehensive TypeScript type definitions for type-safe development.Core Types
WSXRequest
Represents a request from the client to the server.Example
WSXResponse
Represents a response from the server to the client.Example
WSXOOBUpdate
Represents an out-of-band update for multiple element updates.Example
WSXConnection
Represents a WebSocket connection on the server side.Example
Handler Types
WSXHandler
Type definition for request handlers.Example
WSXErrorHandler
Type definition for error handlers.Example
WSXMiddleware
Type definition for middleware functions.Example
Client Types
WSXClientOptions
Configuration options for the WSX client.Example
WSXSendOptions
Options for sending requests.Example
WSXEventMap
Type map for WSX client events.Example
Server Types
WSXServerOptions
Configuration options for the WSX server.Example
WSXAdapter
Interface for server adapters.Example
MessageHandler
Type for message handling functions.Utility Types
WSXHtmlHelper
Type for the HTML template helper function.Example
WSXSwapType
Union type for content swap types.Example
WSXTriggerType
Union type for trigger types.WSXRequestStatus
Union type for request statuses.Generic Types
WSXData
Generic type for request data.Example
WSXResult
Generic type for handler results.Example
Validation Types
WSXValidationRule
Type for validation rules.Example
WSXValidationResult
Type for validation results.Authentication Types
WSXUser
Type for authenticated users.Example
WSXAuthContext
Type for authentication context.Configuration Types
WSXConfig
Type for global WSX configuration.Module Declaration
Global Types
Module Exports
Usage Examples
Client-Side Usage
Server-Side Usage
Best Practices
- Use Strict Types: Enable strict TypeScript mode for better type checking
- Generic Constraints: Use generic constraints for better type inference
- Interface Segregation: Keep interfaces focused and minimal
- Type Guards: Use type guards for runtime type checking
- Utility Types: Leverage TypeScript utility types for transformations
- Documentation: Document complex types with JSDoc comments
- Validation: Combine TypeScript types with runtime validation
Next Steps
- Learn about Client API Reference for detailed method documentation
- Explore Performance Optimization for type-safe performance patterns
- Understand Security Best Practices for secure type implementations