UNPKG

1.74 kBTypeScriptView Raw
1/**
2 * These are types for things that are present in the `experimental` builds of React but not yet
3 * on a stable build.
4 *
5 * Once they are promoted to stable they can just be moved to the main index file.
6 *
7 * To load the types declared here in an actual project, there are three ways. The easiest one,
8 * if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
9 * is to add `"react-dom/experimental"` to the `"types"` array.
10 *
11 * Alternatively, a specific import syntax can to be used from a typescript file.
12 * This module does not exist in reality, which is why the {} is important:
13 *
14 * ```ts
15 * import {} from 'react-dom/experimental'
16 * ```
17 *
18 * It is also possible to include it through a triple-slash reference:
19 *
20 * ```ts
21 * /// <reference types="react-dom/experimental" />
22 * ```
23 *
24 * Either the import or the reference only needs to appear once, anywhere in the project.
25 */
26
27// See https://github.com/facebook/react/blob/main/packages/react-dom/index.experimental.js to see how the exports are declared,
28// but confirm with published source code (e.g. https://unpkg.com/react-dom@experimental) that these exports end up in the published code
29
30import React = require('react');
31import ReactDOM = require('./next');
32
33export {};
34
35declare module '.' {
36 interface FormStatusNotPending {
37 pending: false;
38 data: null;
39 method: null;
40 action: null;
41 }
42
43 interface FormStatusPending {
44 pending: true;
45 data: FormData;
46 method: string;
47 action: string | ((formData: FormData) => void | Promise<void>);
48 }
49
50 type FormStatus = FormStatusPending | FormStatusNotPending;
51
52 function experimental_useFormStatus(): FormStatus;
53}
54
\No newline at end of file