mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Label dictionary keys in community-cli-plugin dev server (#59986)
Summary:
Add key labels to the indexer types in the dev server `/message` and `/events` socket handlers and their tests (`{[string]: T}` becomes `{[key: string]: T}`). This matches the stricter Flow configuration used to type-check these files downstream, which requires dictionary key labels.
Changelog: [Internal]
Differential Revision: D131543175
This commit is contained in:
1 parent
728d49ef1d
commit
61a03afdb5
4 files changed
+8
-8
No files matched your search
@@ -16,7 +16,7 @@ import {startTestServer, waitUntil} from './SocketTestUtils';
|
||||
jest.useRealTimers();
|
||||
|
||||
const logger = {warn: jest.fn(), error: jest.fn()};
|
||||
const broadcast = jest.fn<[string, ?{[string]: unknown}], void>();
|
||||
const broadcast = jest.fn<[string, ?{[key: string]: unknown}], void>();
|
||||
|
||||
let testServer: TestServer;
|
||||
let eventsSocket: ReturnType<typeof createEventsSocket>;
|
||||
@@ -64,7 +64,7 @@ describe('/events', () => {
|
||||
|
||||
test('logs an event that cannot be serialized', async () => {
|
||||
const client = await testServer.connect('/events');
|
||||
const circular: {[string]: unknown} = {};
|
||||
const circular: {[key: string]: unknown} = {};
|
||||
circular.self = circular;
|
||||
|
||||
eventsSocket.reportEvent(circular);
|
||||
|
||||
@@ -32,7 +32,7 @@ type DevServerMiddleware = Readonly<{
|
||||
middleware: Server,
|
||||
websocketEndpoints: {[path: string]: ws$WebSocketServer},
|
||||
messageSocket: Readonly<{
|
||||
broadcast: (method: string, params?: ?{[string]: unknown}) => void,
|
||||
broadcast: (method: string, params?: ?{[key: string]: unknown}) => void,
|
||||
}>,
|
||||
eventsSocket: Readonly<{
|
||||
reportEvent: (event: unknown) => void,
|
||||
|
||||
@@ -19,7 +19,7 @@ const PROTOCOL_VERSION = 2;
|
||||
type Options = Readonly<{
|
||||
logger: Logger,
|
||||
serverBaseUrl: URL,
|
||||
broadcast: (method: string, params?: ?{[string]: unknown}) => void,
|
||||
broadcast: (method: string, params?: ?{[key: string]: unknown}) => void,
|
||||
}>;
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ export default function createEventsSocket({
|
||||
function parseCommand(
|
||||
data: unknown,
|
||||
logger: Logger,
|
||||
): ?Readonly<{command: string, params: ?{[string]: unknown}}> {
|
||||
): ?Readonly<{command: string, params: ?{[key: string]: unknown}}> {
|
||||
let message;
|
||||
try {
|
||||
message = JSON.parse(String(data));
|
||||
|
||||
@@ -24,7 +24,7 @@ export type Logger = Readonly<{
|
||||
...
|
||||
}>;
|
||||
|
||||
type Params = Readonly<{[string]: unknown}>;
|
||||
type Params = Readonly<{[key: string]: unknown}>;
|
||||
|
||||
type ClientMessage =
|
||||
| Readonly<{kind: 'broadcast', method: string, params: unknown}>
|
||||
@@ -45,7 +45,7 @@ type ClientMessage =
|
||||
|
||||
type Client = Readonly<{
|
||||
socket: ws$WebSocket,
|
||||
query: Readonly<{[string]: string}>,
|
||||
query: Readonly<{[key: string]: string}>,
|
||||
}>;
|
||||
|
||||
type Options = Readonly<{
|
||||
@@ -130,7 +130,7 @@ export default function createMessageSocket({logger, serverBaseUrl}: Options): {
|
||||
result = clientId;
|
||||
break;
|
||||
case 'getpeers': {
|
||||
const peers: {[string]: Readonly<{[string]: string}>} = {};
|
||||
const peers: {[key: string]: Readonly<{[key: string]: string}>} = {};
|
||||
for (const [otherId, {query}] of clients) {
|
||||
if (otherId !== clientId) {
|
||||
peers[otherId] = query;
|
||||
|
||||
Reference in new issue
Block a user