mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Adopt lib.dom.d.ts in xplat (#58582)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/58582 X-link: https://github.com/react/metro/pull/1943 Changelog: [Internal] Reviewed By: gkz Differential Revision: D120546333 fbshipit-source-id: b64a0f3557fab2c9d67bc381fdbe8b0f089c13a7
This commit is contained in:
1 parent
c9b77eccc8
commit
d2a6ce5f7f
14 files changed
+31
-21
No files matched your search
@@ -79,6 +79,7 @@ export function withFetchSelfSignedCertsForAllTests(
|
||||
// For some reason, setting the `selfSignedCertDispatcher` with `setGlobalDispatcher` doesn't work.
|
||||
// Instead of using `setGlobalDispatcher`, we'll use a spy to intercept the fetch calls and add the dispatcher.
|
||||
fetchSpy.mockImplementation((url, options) =>
|
||||
// $FlowFixMe[cannot-spread-interface]
|
||||
fetchOriginal(url, {
|
||||
...options,
|
||||
// $FlowFixMe[prop-missing]: dispatcher
|
||||
|
||||
@@ -93,6 +93,7 @@ export default function createDevMiddleware({
|
||||
unstable_customInspectorMessageHandler,
|
||||
unstable_trackInspectorProxyEventLoopPerf = false,
|
||||
}: Options): DevMiddlewareAPI {
|
||||
// $FlowFixMe[incompatible-type]
|
||||
const normalizedServerBaseUrl: ReadonlyURL = new URL(serverBaseUrl);
|
||||
|
||||
const experiments = getExperiments(experimentConfig);
|
||||
|
||||
@@ -255,6 +255,7 @@ export default class InspectorProxy implements InspectorProxyQueries {
|
||||
const devtoolsFrontendUrl = getDevToolsFrontendUrl(
|
||||
this.#experiments,
|
||||
webSocketDebuggerUrl,
|
||||
// $FlowFixMe[incompatible-type]
|
||||
new URL(this.#serverBaseUrl),
|
||||
{
|
||||
relative: true,
|
||||
|
||||
@@ -160,6 +160,7 @@ export default function openDebuggerMiddleware({
|
||||
const frontendUrl = getDevToolsFrontendUrl(
|
||||
experiments,
|
||||
target.webSocketDebuggerUrl,
|
||||
// $FlowFixMe[incompatible-type]
|
||||
new URL(serverBaseUrl),
|
||||
{
|
||||
launchId: query.launchId,
|
||||
@@ -214,6 +215,7 @@ export default function openDebuggerMiddleware({
|
||||
Location: getDevToolsFrontendUrl(
|
||||
experiments,
|
||||
target.webSocketDebuggerUrl,
|
||||
// $FlowFixMe[incompatible-type]
|
||||
new URL(serverBaseUrl),
|
||||
{
|
||||
relative: true,
|
||||
|
||||
@@ -19,14 +19,10 @@ export interface ReadonlyURLSearchParams {
|
||||
entries(): Iterator<[string, string]>;
|
||||
keys(): Iterator<string>;
|
||||
values(): Iterator<string>;
|
||||
forEach<This>(
|
||||
callback: (
|
||||
this: This,
|
||||
value: string,
|
||||
name: string,
|
||||
params: URLSearchParams,
|
||||
) => unknown,
|
||||
thisArg: This,
|
||||
forEach(
|
||||
callbackfn: (value: string, key: string, parent: URLSearchParams) => void,
|
||||
// $FlowExpectedError[unclear-type]
|
||||
thisArg?: any,
|
||||
): void;
|
||||
toString(): string;
|
||||
@@iterator(): Iterator<[string, string]>;
|
||||
|
||||
@@ -316,7 +316,7 @@ declare class MutationRecord {
|
||||
// Always an empty NodeList for `attributes` and `characterData` mutations.
|
||||
// React Native currently only supports `childList`, so this contains the
|
||||
// added nodes for that mutation type.
|
||||
readonly addedNodes: NodeList<Node>;
|
||||
readonly addedNodes: NodeListOf<Node>;
|
||||
// Always `null` in React Native (only `childList` mutations are supported).
|
||||
readonly attributeName: null;
|
||||
// Always `null` in React Native (only `childList` mutations are supported).
|
||||
@@ -329,7 +329,7 @@ declare class MutationRecord {
|
||||
// Always an empty NodeList for `attributes` and `characterData` mutations.
|
||||
// React Native currently only supports `childList`, so this contains the
|
||||
// removed nodes for that mutation type.
|
||||
readonly removedNodes: NodeList<Node>;
|
||||
readonly removedNodes: NodeListOf<Node>;
|
||||
readonly target: Node;
|
||||
// React Native currently only supports `childList` mutations.
|
||||
readonly type: 'childList';
|
||||
|
||||
@@ -551,7 +551,7 @@ interface Animatable {
|
||||
getAnimations(options?: GetAnimationsOptions): Animation[];
|
||||
}
|
||||
|
||||
type AnimationPlaybackEvent$Init = Event$Init & {
|
||||
type AnimationPlaybackEvent$Init = EventInit & {
|
||||
currentTime?: number | null,
|
||||
timelineTime?: number | null,
|
||||
...
|
||||
|
||||
@@ -616,6 +616,8 @@ type Event$Init = {
|
||||
...
|
||||
};
|
||||
|
||||
type EventInit = Event$Init;
|
||||
|
||||
// https://dom.spec.whatwg.org/#interface-event
|
||||
declare class Event {
|
||||
constructor(type: string, eventInitDict?: Event$Init): void;
|
||||
@@ -1312,7 +1314,7 @@ declare class Node extends EventTarget {
|
||||
outerText?: string;
|
||||
}
|
||||
|
||||
declare class NodeList<T> {
|
||||
declare class NodeList<T = Node> {
|
||||
@@iterator(): Iterator<T>;
|
||||
length: number;
|
||||
item(index: number): T;
|
||||
@@ -1327,6 +1329,8 @@ declare class NodeList<T> {
|
||||
values(): Iterator<T>;
|
||||
}
|
||||
|
||||
type NodeListOf<T extends Node> = NodeList<T>;
|
||||
|
||||
declare class NamedNodeMap {
|
||||
@@iterator(): Iterator<Attr>;
|
||||
length: number;
|
||||
|
||||
Vendored
+1
@@ -26,6 +26,7 @@ Fantom.unstable_benchmark
|
||||
disableOptimizedBuildCheck: true,
|
||||
})
|
||||
.test('JavaScript shim', () => {
|
||||
// $FlowFixMe[incompatible-type]
|
||||
const task: ConsoleTask = {run: cb => cb()};
|
||||
task.run(fn);
|
||||
})
|
||||
|
||||
+3
@@ -72,6 +72,7 @@ describe('Event Timing API', () => {
|
||||
entry.processingEnd - entry.startTime,
|
||||
);
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
expect(entry.interactionId).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
@@ -125,6 +126,7 @@ describe('Event Timing API', () => {
|
||||
entry.processingEnd - entry.startTime,
|
||||
);
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
expect(entry.interactionId).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
@@ -181,6 +183,7 @@ describe('Event Timing API', () => {
|
||||
|
||||
// TODO: When Fantom provides structured data from mounting manager, add timestamp to operations and verify that the duration includes that.
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
expect(entry.interactionId).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
|
||||
+4
-8
@@ -119,17 +119,13 @@ describe('User Timing', () => {
|
||||
});
|
||||
|
||||
it('casts startTime to a number', () => {
|
||||
const mark = performance.mark('some-mark', {
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
startTime: '10',
|
||||
});
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
const mark = performance.mark('some-mark', {startTime: '10'});
|
||||
|
||||
expect(mark.startTime).toBe(10);
|
||||
|
||||
const mark2 = performance.mark('some-mark', {
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
startTime: null,
|
||||
});
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
const mark2 = performance.mark('some-mark', {startTime: null});
|
||||
|
||||
expect(mark2.startTime).toBe(0);
|
||||
});
|
||||
|
||||
@@ -168,7 +168,7 @@ function ExampleItem(props: {
|
||||
);
|
||||
}
|
||||
|
||||
function nodeListToString(nodeList: NodeList<Node>): string {
|
||||
function nodeListToString(nodeList: NodeList): string {
|
||||
return [...nodeList]
|
||||
.map(node => (node instanceof Element && node.id) || '<unknown-node>')
|
||||
.join(', ');
|
||||
|
||||
@@ -94,6 +94,7 @@ class WebSocketImage extends React.Component<
|
||||
if (event.data instanceof Blob) {
|
||||
const blob = event.data;
|
||||
if (this.state.blob) {
|
||||
// $FlowFixMe[prop-missing]
|
||||
this.state.blob.close();
|
||||
}
|
||||
this.setState({blob});
|
||||
@@ -106,6 +107,7 @@ class WebSocketImage extends React.Component<
|
||||
|
||||
componentUnmount() {
|
||||
if (this.state.blob) {
|
||||
// $FlowFixMe[prop-missing]
|
||||
this.state.blob.close();
|
||||
}
|
||||
this.ws && this.ws.close();
|
||||
@@ -166,6 +168,7 @@ class WebSocketExample extends React.Component<
|
||||
|
||||
_connect = () => {
|
||||
const socket = new WebSocket(this.state.url);
|
||||
// $FlowFixMe[incompatible-type]
|
||||
WS_EVENTS.forEach(ev => socket.addEventListener(ev, this._onSocketEvent));
|
||||
this.setState({
|
||||
socket,
|
||||
@@ -183,6 +186,7 @@ class WebSocketExample extends React.Component<
|
||||
_onSocketEvent = (event: MessageEvent) => {
|
||||
const state: Partial<WebSocketExampleState> = {
|
||||
// $FlowFixMe[prop-missing]
|
||||
// $FlowFixMe[incompatible-use]
|
||||
socketState: event.target.readyState,
|
||||
lastSocketEvent: event.type,
|
||||
};
|
||||
|
||||
@@ -66,6 +66,7 @@ const useJsStalls = (): ({
|
||||
onStall: ({busyTime}) =>
|
||||
setStallsState(state => {
|
||||
// If previous interval was cleared
|
||||
// $FlowFixMe[sketchy-null-number]
|
||||
if (!state.stallIntervalId) {
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user