Skip to content

Commit 8088de8

Browse files
authoredMar 26, 2024··
fix(ai/rsc): Improve typings for StreamableValue (#1225)
1 parent 6a1b2c7 commit 8088de8

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed
 

‎.changeset/eight-points-dress.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ai': patch
3+
---
4+
5+
fix(ai/rsc): improve typings for `StreamableValue`

‎packages/core/rsc/streamable.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ export function createStreamableValue<T = any, E = any>(initialValue?: T) {
213213

214214
return {
215215
/**
216-
* The value of the streamable. This can be returned from a Server Action and received by the client.
216+
* The value of the streamable. This can be returned from a Server Action and
217+
* received by the client. To read the streamed values, use the
218+
* `readStreamableValue` API.
217219
*/
218220
get value() {
219221
return createWrapped(true);

‎packages/core/rsc/types.ts

+19
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,29 @@ export type MutableAIState<AIState> = {
8989

9090
export type StreamablePatch = undefined | [0, string]; // Append string.
9191

92+
/**
93+
* StreamableValue is a value that can be streamed over the network via AI Actions.
94+
* To read the streamed values, use the `readStreamableValue` API.
95+
*/
9296
export type StreamableValue<T = any, E = any> = {
97+
/**
98+
* @internal Use `readStreamableValue` to read the values.
99+
*/
93100
type?: typeof STREAMABLE_VALUE_TYPE;
101+
/**
102+
* @internal Use `readStreamableValue` to read the values.
103+
*/
94104
curr?: T;
105+
/**
106+
* @internal Use `readStreamableValue` to read the values.
107+
*/
95108
error?: E;
109+
/**
110+
* @internal Use `readStreamableValue` to read the values.
111+
*/
96112
diff?: StreamablePatch;
113+
/**
114+
* @internal Use `readStreamableValue` to read the values.
115+
*/
97116
next?: Promise<StreamableValue<T, E>>;
98117
};

‎packages/core/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
33
"compilerOptions": {
4-
"target": "ES2018"
4+
"target": "ES2018",
5+
"stripInternal": true
56
},
67
"include": ["."],
78
"exclude": ["dist", "build", "node_modules"]

0 commit comments

Comments
 (0)
Please sign in to comment.