File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 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() {
6464 * @example const state = getAIState() // Get the entire AI state
6565 * @example const field = getAIState('key') // Get the value of the key
6666 */
67- function getAIState < AI extends AIProvider = any > ( ) : InferAIState < AI , any > ;
67+ function getAIState < AI extends AIProvider = any > ( ) : Readonly <
68+ InferAIState < AI , any >
69+ > ;
6870function getAIState < AI extends AIProvider = any > (
6971 key : keyof InferAIState < AI , any > ,
70- ) : InferAIState < AI , any > [ typeof key ] ;
72+ ) : Readonly < InferAIState < AI , any > [ typeof key ] > ;
7173function getAIState < AI extends AIProvider = any > (
7274 ...args : [ ] | [ key : keyof InferAIState < AI , any > ]
7375) {
@@ -183,10 +185,10 @@ function getMutableAIState<AI extends AIProvider = any>(
183185 ) } " field from the AI state because it's not an object.`,
184186 ) ;
185187 }
186- return store . currentState [ key ] ;
188+ return store . currentState [ key ] as Readonly < AIStateWithKey > ;
187189 }
188190
189- return store . currentState as AIState ;
191+ return store . currentState as Readonly < AIState > ;
190192 } ,
191193 update : function update ( newAIState : NewStateOrUpdater ) {
192194 doUpdate ( newAIState , false ) ;
You can’t perform that action at this time.
0 commit comments