File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' ai ' : patch
3
+ ---
4
+
5
+ ai/rsc: improve getAIState and getMutableAIState types
Original file line number Diff line number Diff line change @@ -64,10 +64,12 @@ export function sealMutableAIState() {
64
64
* @example const state = getAIState() // Get the entire AI state
65
65
* @example const field = getAIState('key') // Get the value of the key
66
66
*/
67
- function getAIState < AI extends AIProvider = any > ( ) : InferAIState < AI , any > ;
67
+ function getAIState < AI extends AIProvider = any > ( ) : Readonly <
68
+ InferAIState < AI , any >
69
+ > ;
68
70
function getAIState < AI extends AIProvider = any > (
69
71
key : keyof InferAIState < AI , any > ,
70
- ) : InferAIState < AI , any > [ typeof key ] ;
72
+ ) : Readonly < InferAIState < AI , any > [ typeof key ] > ;
71
73
function getAIState < AI extends AIProvider = any > (
72
74
...args : [ ] | [ key : keyof InferAIState < AI , any > ]
73
75
) {
@@ -183,10 +185,10 @@ function getMutableAIState<AI extends AIProvider = any>(
183
185
) } " field from the AI state because it's not an object.`,
184
186
) ;
185
187
}
186
- return store . currentState [ key ] ;
188
+ return store . currentState [ key ] as Readonly < AIStateWithKey > ;
187
189
}
188
190
189
- return store . currentState as AIState ;
191
+ return store . currentState as Readonly < AIState > ;
190
192
} ,
191
193
update : function update ( newAIState : NewStateOrUpdater ) {
192
194
doUpdate ( newAIState , false ) ;
You can’t perform that action at this time.
0 commit comments