// Test case for CT-1006: Stream type nested in OpaqueRef inside Opaque union // This mimics the structure of BuiltInLLMState where cancelGeneration: Stream // becomes Opaque>> when returned inside OpaqueRef interface OpaqueRefMethods { get(): T; set(value: T): void; } // OpaqueRef is an intersection of OpaqueRefMethods and T type OpaqueRef = & BrandedCell & OpaqueRefMethods & ( T extends Array ? Array> : T extends object ? { [K in keyof T]: OpaqueRef } : T ); // Opaque is a union: T | OpaqueRef type Opaque = | OpaqueRef | (T extends Array ? Array> : T extends object ? { [K in keyof T]: Opaque } : T); // This mimics BuiltInLLMState structure interface LLMState { pending: boolean; result?: string; error: unknown; cancelGeneration: Stream; // This becomes problematic when wrapped } // When we have OpaqueRef, the cancelGeneration property becomes: // Opaque>> which is the nested structure that triggered CT-1006 interface SchemaRoot { state: OpaqueRef; }