diff --git a/types/react/experimental.d.ts b/types/react/experimental.d.ts index 5c448d90937f1e..79ba1e007c151e 100644 --- a/types/react/experimental.d.ts +++ b/types/react/experimental.d.ts @@ -174,4 +174,11 @@ declare module "." { interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES { srcObject: Blob | MediaSource | MediaStream; } + + // @enableOptimisticKey + export const optimisticKey: unique symbol; + + interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES { + optimisticKey: typeof optimisticKey; + } } diff --git a/types/react/index.d.ts b/types/react/index.d.ts index f16a2622acfb03..750b493498ad1d 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -226,12 +226,20 @@ declare namespace React { type ComponentState = any; + interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {} + /** * A value which uniquely identifies a node among items in an array. * * @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs} */ - type Key = string | number | bigint; + type Key = + | string + | number + | bigint + | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES[ + keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES + ]; /** * @internal The props any component can receive. diff --git a/types/react/test/experimental.tsx b/types/react/test/experimental.tsx index dc46c65d62f4c5..e6ecbca0305caf 100644 --- a/types/react/test/experimental.tsx +++ b/types/react/test/experimental.tsx @@ -209,3 +209,11 @@ function swipeTransitionTest() { > ; } + +function optimisticKeyTest() { +
; +
; +} diff --git a/types/react/ts5.0/experimental.d.ts b/types/react/ts5.0/experimental.d.ts index 5c448d90937f1e..79ba1e007c151e 100644 --- a/types/react/ts5.0/experimental.d.ts +++ b/types/react/ts5.0/experimental.d.ts @@ -174,4 +174,11 @@ declare module "." { interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_MEDIA_SRC_TYPES { srcObject: Blob | MediaSource | MediaStream; } + + // @enableOptimisticKey + export const optimisticKey: unique symbol; + + interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES { + optimisticKey: typeof optimisticKey; + } } diff --git a/types/react/ts5.0/index.d.ts b/types/react/ts5.0/index.d.ts index c9bac1033c8e85..169dc36532488b 100644 --- a/types/react/ts5.0/index.d.ts +++ b/types/react/ts5.0/index.d.ts @@ -226,12 +226,20 @@ declare namespace React { type ComponentState = any; + interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES {} + /** * A value which uniquely identifies a node among items in an array. * * @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs} */ - type Key = string | number | bigint; + type Key = + | string + | number + | bigint + | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES[ + keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_KEY_TYPES + ]; /** * @internal The props any component can receive. diff --git a/types/react/ts5.0/test/experimental.tsx b/types/react/ts5.0/test/experimental.tsx index dc46c65d62f4c5..e6ecbca0305caf 100644 --- a/types/react/ts5.0/test/experimental.tsx +++ b/types/react/ts5.0/test/experimental.tsx @@ -209,3 +209,11 @@ function swipeTransitionTest() { > ; } + +function optimisticKeyTest() { +
; +
; +}