Skip to content

Commit 5355bf5

Browse files
committed
Float types are currently spread out. this moves them to a single place to ensure we properly handle the public type interface in all three renderers
1 parent ce6842d commit 5355bf5

9 files changed

+34
-42
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import type {HostDispatcher} from 'react-dom/src/ReactDOMDispatcher';
10+
import type {HostDispatcher} from 'react-dom/src/shared/ReactDOMTypes';
1111
import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
1212
import type {DOMEventName} from '../events/DOMEventNames';
1313
import type {Fiber, FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
@@ -19,6 +19,12 @@ import type {
1919
import type {ReactScopeInstance} from 'shared/ReactTypes';
2020
import type {AncestorInfoDev} from './validateDOMNesting';
2121
import type {FormStatus} from 'react-dom-bindings/src/shared/ReactDOMFormActions';
22+
import type {
23+
PrefetchDNSOptions,
24+
PreconnectOptions,
25+
PreloadOptions,
26+
PreinitOptions,
27+
} from 'react-dom/src/shared/ReactDOMTypes';
2228

2329
import {NotPending} from 'react-dom-bindings/src/shared/ReactDOMFormActions';
2430
import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostContext';
@@ -2095,7 +2101,7 @@ function preconnectAs(
20952101
}
20962102
}
20972103
2098-
function prefetchDNS(href: string, options?: mixed) {
2104+
function prefetchDNS(href: string, options?: ?PrefetchDNSOptions) {
20992105
if (!enableFloat) {
21002106
return;
21012107
}
@@ -2125,7 +2131,7 @@ function prefetchDNS(href: string, options?: mixed) {
21252131
preconnectAs('dns-prefetch', null, href);
21262132
}
21272133
2128-
function preconnect(href: string, options: ?{crossOrigin?: string}) {
2134+
function preconnect(href: string, options?: ?PreconnectOptions) {
21292135
if (!enableFloat) {
21302136
return;
21312137
}
@@ -2156,13 +2162,6 @@ function preconnect(href: string, options: ?{crossOrigin?: string}) {
21562162
preconnectAs('preconnect', crossOrigin, href);
21572163
}
21582164
2159-
type PreloadOptions = {
2160-
as: string,
2161-
crossOrigin?: string,
2162-
integrity?: string,
2163-
type?: string,
2164-
fetchPriority?: 'high' | 'low' | 'auto',
2165-
};
21662165
function preload(href: string, options: PreloadOptions) {
21672166
if (!enableFloat) {
21682167
return;
@@ -2238,14 +2237,6 @@ function preloadPropsFromPreloadOptions(
22382237
};
22392238
}
22402239
2241-
type PreinitOptions = {
2242-
as: string,
2243-
precedence?: string,
2244-
crossOrigin?: string,
2245-
integrity?: string,
2246-
nonce?: string,
2247-
fetchPriority?: 'high' | 'low' | 'auto',
2248-
};
22492240
function preinit(href: string, options: PreinitOptions) {
22502241
if (!enableFloat) {
22512242
return;

packages/react-dom-bindings/src/server/ReactDOMFlightServerHostDispatcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
PreconnectOptions,
1414
PreloadOptions,
1515
PreinitOptions,
16-
} from 'react-dom/src/ReactDOMDispatcher';
16+
} from 'react-dom/src/shared/ReactDOMTypes';
1717

1818
import {enableFloat} from 'shared/ReactFeatureFlags';
1919

@@ -52,7 +52,7 @@ function prefetchDNS(href: string, options?: ?PrefetchDNSOptions) {
5252
}
5353
}
5454

55-
function preconnect(href: string, options: ?PreconnectOptions) {
55+
function preconnect(href: string, options?: ?PreconnectOptions) {
5656
if (enableFloat) {
5757
if (typeof href === 'string') {
5858
const request = resolveRequest();

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
*/
99

1010
import type {ReactNodeList, ReactCustomFormAction} from 'shared/ReactTypes';
11+
import type {
12+
PrefetchDNSOptions,
13+
PreconnectOptions,
14+
PreloadOptions,
15+
PreinitOptions,
16+
} from 'react-dom/src/shared/ReactDOMTypes';
1117

1218
import {
1319
checkHtmlStringCoercion,
@@ -4894,7 +4900,7 @@ function getResourceKey(as: string, href: string): string {
48944900
return `[${as}]${href}`;
48954901
}
48964902

4897-
export function prefetchDNS(href: string, options?: mixed) {
4903+
export function prefetchDNS(href: string, options?: ?PrefetchDNSOptions) {
48984904
if (!enableFloat) {
48994905
return;
49004906
}
@@ -4953,7 +4959,7 @@ export function prefetchDNS(href: string, options?: mixed) {
49534959
}
49544960
}
49554961

4956-
export function preconnect(href: string, options?: ?{crossOrigin?: string}) {
4962+
export function preconnect(href: string, options?: ?PreconnectOptions) {
49574963
if (!enableFloat) {
49584964
return;
49594965
}
@@ -5016,13 +5022,6 @@ export function preconnect(href: string, options?: ?{crossOrigin?: string}) {
50165022
}
50175023
}
50185024

5019-
type PreloadOptions = {
5020-
as: string,
5021-
crossOrigin?: string,
5022-
integrity?: string,
5023-
type?: string,
5024-
fetchPriority?: 'high' | 'low' | 'auto',
5025-
};
50265025
export function preload(href: string, options: PreloadOptions) {
50275026
if (!enableFloat) {
50285027
return;
@@ -5161,14 +5160,6 @@ export function preload(href: string, options: PreloadOptions) {
51615160
}
51625161
}
51635162

5164-
type PreinitOptions = {
5165-
as: string,
5166-
precedence?: string,
5167-
crossOrigin?: string,
5168-
integrity?: string,
5169-
nonce?: string,
5170-
fetchPriority?: 'high' | 'low' | 'auto',
5171-
};
51725163
function preinit(href: string, options: PreinitOptions): void {
51735164
if (!enableFloat) {
51745165
return;

packages/react-dom-bindings/src/server/ReactFlightServerConfigDOM.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
PreconnectOptions,
1313
PreloadOptions,
1414
PreinitOptions,
15-
} from 'react-dom/src/ReactDOMDispatcher';
15+
} from 'react-dom/src/shared/ReactDOMTypes';
1616

1717
import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
1818
const ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;

packages/react-dom/src/ReactDOMSharedInternals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import type {HostDispatcher} from './ReactDOMDispatcher';
10+
import type {HostDispatcher} from './shared/ReactDOMTypes';
1111

1212
type InternalsType = {
1313
usingClientEntryPoint: boolean,

packages/react-dom/src/client/ReactDOM.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ import {
5555
} from 'react-dom-bindings/src/events/ReactDOMControlledComponent';
5656
import Internals from '../ReactDOMSharedInternals';
5757

58-
export {prefetchDNS, preconnect, preload, preinit} from '../ReactDOMFloat';
58+
export {
59+
prefetchDNS,
60+
preconnect,
61+
preload,
62+
preinit,
63+
} from '../shared/ReactDOMFloat';
5964
export {useFormStatus} from 'react-dom-bindings/src/shared/ReactDOMFormActions';
6065

6166
if (__DEV__) {

packages/react-dom/src/server/ReactDOMServerRenderingStub.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
* @flow
88
*/
99

10-
export {preinit, preload, preconnect, prefetchDNS} from '../ReactDOMFloat';
10+
export {
11+
preinit,
12+
preload,
13+
preconnect,
14+
prefetchDNS,
15+
} from '../shared/ReactDOMFloat';
1116
export {useFormStatus as experimental_useFormStatus} from 'react-dom-bindings/src/shared/ReactDOMFormActions';
1217

1318
export function createPortal() {

packages/react-dom/src/ReactDOMFloat.js renamed to packages/react-dom/src/shared/ReactDOMFloat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
PreconnectOptions,
1111
PreloadOptions,
1212
PreinitOptions,
13-
} from './ReactDOMDispatcher';
13+
} from './ReactDOMTypes';
1414

1515
import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
1616
const Dispatcher = ReactDOMSharedInternals.Dispatcher;

0 commit comments

Comments
 (0)