UNPKG

1.8 kBTypeScriptView Raw
1/**
2 * These are types for things that are present in the upcoming React 18 release.
3 *
4 * Once React 18 is released they can just be moved to the main index file.
5 *
6 * To load the types declared here in an actual project, there are three ways. The easiest one,
7 * if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
8 * is to add `"react-dom/next"` to the `"types"` array.
9 *
10 * Alternatively, a specific import syntax can to be used from a typescript file.
11 * This module does not exist in reality, which is why the {} is important:
12 *
13 * ```ts
14 * import {} from 'react-dom/next'
15 * ```
16 *
17 * It is also possible to include it through a triple-slash reference:
18 *
19 * ```ts
20 * /// <reference types="react-dom/next" />
21 * ```
22 *
23 * Either the import or the reference only needs to appear once, anywhere in the project.
24 */
25
26// See https://github.com/facebook/react/blob/main/packages/react-dom/index.js to see how the exports are declared,
27// but confirm with published source code (e.g. https://unpkg.com/react-dom@next) that these exports end up in the published code
28
29import React = require('react');
30import ReactDOM = require('.');
31
32export {};
33
34declare module '.' {
35 type PreloadAs = 'font' | 'script' | 'style';
36 interface PreloadOptions {
37 as: PreloadAs;
38 crossOrigin?: string | undefined;
39 integrity?: string | undefined;
40 }
41 function preload(href: string, options?: PreloadOptions): void;
42
43 type PreinitAs = 'script' | 'style';
44 interface PreinitOptions {
45 as: PreinitAs;
46 crossOrigin?: string | undefined;
47 precedence?: string | undefined;
48 integrity?: string | undefined;
49 nonce?: string | undefined;
50 }
51 function preinit(href: string, options?: PreinitOptions): void;
52}