Advanced TypeScript for Harness Builders

10. Intersection Types

The & operator merges two types — all properties from both sides must be present.

The & operator merges two types. All properties from both sides must be present.

File: packages/ai/src/types.ts L118

export type ProviderStreamOptions = StreamOptions & Record<string, unknown>;

This creates a type that has all StreamOptions fields plus accepts arbitrary extra keys. Used when providers need custom options beyond the base interface.

File: packages/coding-agent/src/core/extensions/types.ts L872

): event is ToolCallEvent & { toolName: TName; input: TInput };

Intersection narrows ToolCallEvent to a specific tool name and input shape.


Open this chapter inside the full course