Skip to content

Commit

Permalink
Annotate implicit instantiations in xplat, defaulting to any
Browse files Browse the repository at this point in the history
Summary:
Add explicit annotations to underconstrained implicit instantiations as required for Flow's Local Type Inference project. This codemod prepares the codebase to match Flow's new typechecking algorithm. The new algorithm will make Flow more reliable and predictable.

This diff adds `any` or `$FlowFixMe` in cases where more precise types could not be determined.

Details:
- Codemod script: `.facebook/flowd codemod annotate-implicit-instantiations ../../xplat/js --default-any --write`
- Local Type Inference announcement: [post](https://fb.workplace.com/groups/flowlang/posts/788206301785035)
- Support group: [Flow Support](https://fb.workplace.com/groups/flow)

drop-conflicts
bypass-lint

Reviewed By: SamChou19815

Differential Revision: D41226960

fbshipit-source-id: e5e3edbb1aed849f90cc683a4d416a9a2f8f3a19
  • Loading branch information
mvitousek authored and facebook-github-bot committed Nov 11, 2022
1 parent e57befd commit cd679bf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/metro-file-map/src/__tests__/HasteFS-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import HasteFS from '../HasteFS';

jest.mock('../lib/fast_path', () => ({
resolve: (a, b) => b,
relative: jest.requireActual('path').relative,
relative: jest.requireActual<{relative: mixed}>('path').relative,
}));

describe('matchFilesWithContext', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/metro-file-map/src/crawlers/watchman/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @oncall react_native
*/

import type {WatchmanClockSpec} from '../../flow-types';
import type {
CrawlerOptions,
FileData,
Expand All @@ -18,10 +19,10 @@ import type {
} from '../../flow-types';
import type {WatchmanQueryResponse, WatchmanWatchResponse} from 'fb-watchman';

import {planQuery} from './planQuery';
import H from '../../constants';
import * as fastPath from '../../lib/fast_path';
import normalizePathSep from '../../lib/normalizePathSep';
import {planQuery} from './planQuery';
import invariant from 'invariant';
import * as path from 'path';
import {performance} from 'perf_hooks';
Expand Down Expand Up @@ -60,7 +61,7 @@ module.exports = async function watchmanCrawl({
}> {
perfLogger?.point('watchmanCrawl_start');

const newClocks = new Map();
const newClocks = new Map<Path, WatchmanClockSpec>();

const client = new watchman.Client();
abortSignal?.addEventListener('abort', () => client.end());
Expand Down
6 changes: 3 additions & 3 deletions packages/metro-transform-worker/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ it('allows replacing the collectDependencies implementation', async () => {
'metro-transform-worker/__virtual__/collectModifiedDependencies',
() =>
jest.fn((ast, opts) => {
const metroCoreCollectDependencies = jest.requireActual(
'metro/src/ModuleGraph/worker/collectDependencies',
);
const metroCoreCollectDependencies = jest.requireActual<
(empty, empty) => {dependencies: {map: mixed => mixed}},
>('metro/src/ModuleGraph/worker/collectDependencies');
const collectedDeps = metroCoreCollectDependencies(ast, opts);
return {
...collectedDeps,
Expand Down
5 changes: 4 additions & 1 deletion packages/metro/src/DeltaBundler/__tests__/resolver-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ type MockFSDirContents = $ReadOnly<{
});

if (osPlatform === 'win32') {
jest.mock('path', () => jest.requireActual('path').win32);
jest.mock(
'path',
() => jest.requireActual<{win32: mixed}>('path').win32,
);
jest.mock(
'fs',
() => new (require('metro-memory-fs'))({platform: 'win32'}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('getContextModuleTemplate', () => {

test('creates posix paths on windows for sync template', () => {
jest.resetModules();
jest.mock('path', () => jest.requireActual('path').win32);
jest.mock('path', () => jest.requireActual<{win32: mixed}>('path').win32);
const {
getContextModuleTemplate: getWindowsTemplate,
} = require('../contextModuleTemplates');
Expand Down

0 comments on commit cd679bf

Please sign in to comment.