File tree Expand file tree Collapse file tree 6 files changed +48
-2
lines changed
Expand file tree Collapse file tree 6 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -174,4 +174,11 @@ declare module "." {
174174 interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {
175175 srcObject : Blob | MediaSource | MediaStream ;
176176 }
177+
178+ // @enableOptimisticKey
179+ export const optimisticKey : unique symbol ;
180+
181+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {
182+ optimisticKey : typeof optimisticKey ;
183+ }
177184}
Original file line number Diff line number Diff line change @@ -226,12 +226,20 @@ declare namespace React {
226226
227227 type ComponentState = any ;
228228
229+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES { }
230+
229231 /**
230232 * A value which uniquely identifies a node among items in an array.
231233 *
232234 * @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs }
233235 */
234- type Key = string | number | bigint ;
236+ type Key =
237+ | string
238+ | number
239+ | bigint
240+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES [
241+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES
242+ ] ;
235243
236244 /**
237245 * @internal The props any component can receive.
Original file line number Diff line number Diff line change @@ -209,3 +209,11 @@ function swipeTransitionTest() {
209209 >
210210 </ React . ViewTransition > ;
211211}
212+
213+ function optimisticKeyTest ( ) {
214+ < div key = { React . optimisticKey } /> ;
215+ < div
216+ // @ts -expect-error -- random symbols are not allowed.
217+ key = { Symbol ( "foreign-key" ) }
218+ /> ;
219+ }
Original file line number Diff line number Diff line change @@ -174,4 +174,11 @@ declare module "." {
174174 interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES {
175175 srcObject : Blob | MediaSource | MediaStream ;
176176 }
177+
178+ // @enableOptimisticKey
179+ export const optimisticKey : unique symbol ;
180+
181+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {
182+ optimisticKey : typeof optimisticKey ;
183+ }
177184}
Original file line number Diff line number Diff line change @@ -226,12 +226,20 @@ declare namespace React {
226226
227227 type ComponentState = any ;
228228
229+ interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES { }
230+
229231 /**
230232 * A value which uniquely identifies a node among items in an array.
231233 *
232234 * @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs }
233235 */
234- type Key = string | number | bigint ;
236+ type Key =
237+ | string
238+ | number
239+ | bigint
240+ | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES [
241+ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES
242+ ] ;
235243
236244 /**
237245 * @internal The props any component can receive.
Original file line number Diff line number Diff line change @@ -209,3 +209,11 @@ function swipeTransitionTest() {
209209 >
210210 </ React . ViewTransition > ;
211211}
212+
213+ function optimisticKeyTest ( ) {
214+ < div key = { React . optimisticKey } /> ;
215+ < div
216+ // @ts -expect-error -- random symbols are not allowed.
217+ key = { Symbol ( "foreign-key" ) }
218+ /> ;
219+ }
You can’t perform that action at this time.
0 commit comments