Skip to content

Commit 416c1ef

Browse files
panagosg7facebook-github-bot
authored andcommitted
manual annotations in preparation of natural inference rollout in xplat/js
Summary: X-link: react/react-native#51487 The Flow team is improving the way Flow infers type for primitive literals. This diff prepares the codebase for the new behavior by adding type annotations, or annotations of the form `'abc' as const`. Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D75114156 fbshipit-source-id: e3175af85cdd2388c3b45af4beb314f334e3f9b5
1 parent d620613 commit 416c1ef

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

packages/buck-worker-tool/src/worker-tool.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ function handshakeResponse(message: IncomingMessage) {
181181

182182
return {
183183
id: message.id,
184-
type: 'handshake',
185-
protocol_version: '0',
184+
type: 'handshake' as const,
185+
protocol_version: '0' as const,
186186
capabilities: ([]: []),
187187
};
188188
}
@@ -281,13 +281,17 @@ function shouldDebugCommand(argsString: string) {
281281
}
282282

283283
const error = (id: number, exitCode: number) => ({
284-
type: 'error',
284+
type: 'error' as const,
285285
id,
286286
exit_code: exitCode,
287287
});
288288
const unknownMessage = (id: number) => error(id, 1);
289289
const invalidMessage = (id: number) => error(id, 2);
290290
const commandError = (id: number) => error(id, 3);
291-
const success = (id: number) => ({type: 'result', id, exit_code: 0});
291+
const success = (id: number) => ({
292+
type: 'result' as const,
293+
id,
294+
exit_code: 0 as const,
295+
});
292296

293297
module.exports = buckWorker;

packages/metro/src/DeltaBundler/__tests__/Graph-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*/
3434

3535
import type {RequireContext} from '../../lib/contextModule';
36+
import type {RequireContextParams} from '../../ModuleGraph/worker/collectDependencies';
3637
import type {Result} from '../Graph';
3738
import type {
3839
Dependency,
@@ -81,7 +82,7 @@ const files = new CountingSet<string>();
8182
let transformOverrides: Map<string, TransformFn<MixedOutput>>;
8283

8384
let graph: TestGraph;
84-
let options;
85+
let options: Options<>;
8586

8687
let entryModule;
8788
let moduleFoo;
@@ -2934,7 +2935,7 @@ describe('require.context', () => {
29342935
};
29352936
});
29362937

2937-
const ctxParams = {
2938+
const ctxParams: RequireContextParams = {
29382939
recursive: true,
29392940
mode: 'sync',
29402941
filter: {pattern: '.*', flags: ''},
@@ -3268,7 +3269,7 @@ describe('require.context', () => {
32683269
});
32693270

32703271
describe('when two distinct contexts match the same file', () => {
3271-
const narrowCtxParams = {
3272+
const narrowCtxParams: RequireContextParams = {
32723273
recursive: true,
32733274
mode: 'sync',
32743275
filter: {pattern: '\\./narrow/.*', flags: ''},

0 commit comments

Comments
 (0)