Type Alias: AiResponse<T>
AiResponse<
T> = {data:T;metadata:AiResponseMetadata;status:"success"; } | {data:undefined;error:AiResponseError;metadata:AiResponseMetadata;status:"error"; } | {data:Partial<T>;error?:AiResponseError;metadata:AiResponseMetadata;status:"partial"; }
Defined in: src/ai/types.ts:84
Discriminated union AI response envelope on status.
Type Parameters​
T​
T
Remarks​
Narrow on status to get type-safe access to data and error:
'success'—dataisT, noerror'error'—dataisundefined,erroris populated'partial'—dataisPartial<T>, optionalerror
Intent​
Provide type-safe AI result handling without casting.
Example​
function handle<T>(response: AiResponse<T>): T | undefined {
if (response.status === 'success') {
return response.data; // T
}
return undefined;
}