Skip to main content

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

WSXBinaryData

Represents binary payloads exchanged over stream channels.

WSXJSONMessage

Represents a JSON message transferred over WSX channels.

WSXJSONSendOptions

Optional settings when sending JSON messages.

WSXStreamMessage

Metadata attached to a binary stream frame.

WSXStreamSendOptions

Optional settings when sending stream frames.

WSXConnection

Represents a WebSocket connection on the server side.

Example

Handler Types

WSXHandler

Type definition for request handlers.

Example

WSXJSONHandler

Type definition for JSON channel handlers.

WSXStreamHandler

Type definition for binary stream handlers.

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

  1. Use Strict Types: Enable strict TypeScript mode for better type checking
  2. Generic Constraints: Use generic constraints for better type inference
  3. Interface Segregation: Keep interfaces focused and minimal
  4. Type Guards: Use type guards for runtime type checking
  5. Utility Types: Leverage TypeScript utility types for transformations
  6. Documentation: Document complex types with JSDoc comments
  7. Validation: Combine TypeScript types with runtime validation

Next Steps