Skip to content

Commit

Permalink
Merge master changes back into main (flow-typed#4480)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianzchen committed Jul 29, 2023
1 parent 47d5624 commit 830640f
Show file tree
Hide file tree
Showing 16 changed files with 700 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"node-stream-zip": "^1.15.0",
"prettier": "^1.19.1",
"rimraf": "^3.0.2",
"semver": "7.3.2",
"semver": "^7.5.4",
"simple-git": "^3.10.0",
"table": "^6.7.3",
"which": "^2.0.2",
Expand Down
22 changes: 21 additions & 1 deletion cli/src/lib/__tests__/semver-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// @flow

import {stringToVersion, getRangeLowerBound} from '../semver.js';
import {
stringToVersion,
getRangeLowerBound,
getRangeUpperBound,
} from '../semver.js';
import {Range} from 'semver';

describe('semver', () => {
Expand Down Expand Up @@ -44,16 +48,32 @@ describe('semver', () => {
});
});
});

describe('getRangeLowerBound', () => {
it('gets correct lower bound for string', () => {
expect(getRangeLowerBound('v1.2.x')).toEqual('1.2.0');
expect(getRangeLowerBound('v1.x.x')).toEqual('1.0.0');
expect(getRangeLowerBound('^v0.x.x')).toEqual('0.0.0');
});

it('gets correct lower bound for string', () => {
expect(getRangeLowerBound(new Range('v1.2.x'))).toEqual('1.2.0');
expect(getRangeLowerBound(new Range('v1.x.x'))).toEqual('1.0.0');
expect(getRangeLowerBound(new Range('^v0.x.x'))).toEqual('0.0.0');
});
});

describe('getRangeUpperBound', () => {
it('gets correct upper bound for string', () => {
expect(getRangeUpperBound('v1.2.x')).toEqual('1.3.0-0');
expect(getRangeUpperBound('v1.x.x')).toEqual('2.0.0-0');
expect(getRangeUpperBound('^v0.x.x')).toEqual('1.0.0-0');
});

it('gets correct upper bound for string', () => {
expect(getRangeUpperBound(new Range('v1.2.x'))).toEqual('1.3.0-0');
expect(getRangeUpperBound(new Range('v1.x.x'))).toEqual('2.0.0-0');
expect(getRangeUpperBound(new Range('^v0.x.x'))).toEqual('1.0.0-0');
});
});
});
27 changes: 25 additions & 2 deletions cli/src/lib/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,39 @@ export function emptyVersion(): Version {
};
}

/**
* Find the lowest compatible explicit version based on a version range
* of a flow-typed definition
* ie: a type definition is 1.2.x, and the lower bound of that would be 1.2.0
*/
export function getRangeLowerBound(rangeRaw: string | semver.Range): string {
const range =
typeof rangeRaw === 'string' ? new semver.Range(rangeRaw) : rangeRaw;
// Fix for semver returning a bad comparator when the range is 'v0.x.x'
return range.set[0][0].semver.version || '0.0.0';

// When the range only has one object in the set, it implicitly means
// there is a range of anything up to the upper bound.
// Therefore we return `'0.0.0'`.
if (range.set[0].length === 1) {
return '0.0.0';
}
return range.set[0][0].semver.version;
}

/**
* Find the highest compatible explicit version based on a version range
* of a flow-typed definition
* ie: a type definition is 1.2.x, and the upper bound of that would be 1.3.0
*/
export function getRangeUpperBound(rangeRaw: string | semver.Range): string {
const range =
typeof rangeRaw === 'string' ? new semver.Range(rangeRaw) : rangeRaw;

// When the range only has one object in the set, it implicitly means
// there is a range of anything up to the upper bound.
// So we'll return the first object version representing the upper bound.
if (range.set[0].length === 1) {
return range.set[0][0].semver.version;
}
return range.set[0][1].semver.version;
}

Expand Down
19 changes: 7 additions & 12 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1899,9 +1899,9 @@ camelcase@^6.2.0:
integrity sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==

caniuse-lite@^1.0.30001280:
version "1.0.30001489"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001489.tgz"
integrity sha512-x1mgZEXK8jHIfAxm+xgdpHpk50IN3z3q3zP261/WS+uvePxW8izXuCu6AHz0lkuYTlATDehiZ/tNyYBdSQsOUQ==
version "1.0.30001517"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001517.tgz#90fabae294215c3495807eb24fc809e11dc2f0a8"
integrity sha512-Vdhm5S11DaFVLlyiKu4hiUTkpZu+y1KA/rZZqVQfOD5YdDT/eQKlkt7NaE0WGOFgX32diqt9MiP9CAiFeRklaA==

chalk@^2.0.0:
version "2.4.2"
Expand Down Expand Up @@ -4069,11 +4069,6 @@ semver@7.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==

semver@7.3.2:
version "7.3.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==

semver@^5.4.1, semver@^5.6.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
Expand All @@ -4084,10 +4079,10 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.2.1, semver@^7.3.2:
version "7.3.5"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
semver@^7.2.1, semver@^7.3.2, semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ declare class ApolloClient$ApolloLink {
concat(next: ApolloClient$ApolloLink | ApolloClient$RequestHandler): ApolloClient$ApolloLink;
request(operation: ApolloClient$Operation, forward?: ApolloClient$NextLink): ZenObservable$Observable<ApolloClient$FetchResult<>> | null;
onError(error: any, observer?: ZenObservable$Observer<ApolloClient$FetchResult<>>): false | void;
setOnError(fn: $PropertyType<ApolloClient$ApolloLink, "onError">): this;
setOnError(
fn: (error: any, observer?: ZenObservable$Observer<ApolloClient$FetchResult<>>) => false | void,
): this;
}

declare module "@apollo/client" {
Expand Down Expand Up @@ -2214,8 +2216,7 @@ declare module "@apollo/client" {

// @apollo/client/link/http/parseAndCheckHttpResponse.d.ts

declare export type ServerParseError = {|
...Error,
declare export type ServerParseError = Error & {|
response: Response,
statusCode: number,
bodyText: string,
Expand Down Expand Up @@ -2307,7 +2308,7 @@ declare module "@apollo/client" {
fallbackConfig: HttpConfig,
...configs: Array<HttpConfig>
): {
options: { ...HttpConfig, [key: string]: any, ... },
options: HttpConfig & { [key: string]: any, ... },
body: Body,
...
};
Expand All @@ -2316,7 +2317,7 @@ declare module "@apollo/client" {
printer: Printer,
...configs: HttpConfig[]
): {
options: { ...HttpConfig, [key: string]: any, ... },
options: HttpConfig & { [key: string]: any, ... },
body: Body,
...
};
Expand Down Expand Up @@ -2351,8 +2352,7 @@ declare module "@apollo/client" {

// @apollo/client/link/utils/throwServerError.d.ts

declare type ServerError = {
...Error,
declare type ServerError = Error & {
response: Response,
result: { [key: string]: any, ... },
statusCode: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MockedProvider } from "@apollo/client/testing";
import * as React from 'react';
import { RetryLink } from '@apollo/client/link/retry';

const client = new ApolloClient({ cache: new ApolloCache() });
const client = new ApolloClient<{ ... }>({ cache: new ApolloCache() });

type MutationData = {|
id: string,
Expand Down
6 changes: 3 additions & 3 deletions definitions/npm/chai_v4.x.x/flow_v0.201.x-/chai_v4.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare module "chai" {
eql: (value: T, message?: string) => ExpectChain<T>,
equal: (value: T, message?: string) => ExpectChain<T>,
equals: (value: T, message?: string) => ExpectChain<T>,
above: (value: T & number, message?: string) => ExpectChain<T>,
above: (value: number, message?: string) => ExpectChain<T>,
gt: (value: T & number, message?: string) => ExpectChain<T>,
greaterThan: (value: T & number, message?: string) => ExpectChain<T>,
least: (value: T & number, message?: string) => ExpectChain<T>,
Expand Down Expand Up @@ -223,8 +223,8 @@ declare module "chai" {
static notInclude(exp: string, inc: mixed, msg?: string): void;
static notInclude<T>(exp: Array<T>, inc: T, msg?: string): void;

static deepInclude<T>(haystack : T[] | string, needle : $Shape<T>, msg?: string) : void;
static notDeepInclude<T>(haystack : T[] | string, needle : $Shape<T>, msg?: string) : void;
static deepInclude<T>(haystack : T[] | string, needle : Partial<T>, msg?: string) : void;
static notDeepInclude<T>(haystack : T[] | string, needle : Partial<T>, msg?: string) : void;

static match(exp: mixed, re: RegExp, msg?: string): void;
static notMatch(exp: mixed, re: RegExp, msg?: string): void;
Expand Down
38 changes: 20 additions & 18 deletions definitions/npm/chai_v4.x.x/test_chai_v4.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ expect(
false
);

// $FlowExpectedError
// $FlowExpectedError[prop-missing]
expect(1).to.what("nope");

// Fail message
Expand All @@ -24,21 +24,21 @@ config.includeStack = true;
config.showDiff = true;
config.truncateThreshold = 200;

// $FlowExpectedError
// $FlowExpectedError[incompatible-type]
config.includeStack = 100;

// $FlowExpectedError
// $FlowExpectedError[incompatible-type]
config.showDiff = 100;

// $FlowExpectedError
// $FlowExpectedError[incompatible-type]
config.truncateThreshold = true;

/**
* Simple Assertions
*/
expect(1).to.be.a("number");
expect([1]).to.be.an("array");
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect(1).to.be.a(["fail"]);

expect([1]).to.include(1);
Expand Down Expand Up @@ -69,7 +69,7 @@ expect({ a: { b: 1 } }).to.have.nested.property("a.b", 1);
expect([1, 2, 3]).to.have.length.above(2);
expect([1, 2, 3]).to.have.lengthOf(3);
expect([1, 2, 3]).to.have.length(3);
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect([1, 2, 3]).to.have.length("three");

expect("abc").to.match(/[a-z]{3}/);
Expand All @@ -92,7 +92,7 @@ expect({}).to.respondTo("bar");
expect(Error).itself.to.respondTo("bar");

expect(1).to.satisfy(x => x > 0);
// $FlowExpectedError
// $FlowExpectedError[unsafe-arithmetic]
expect(1).to.satisfy((x, y) => x * y);

expect(0.3 - 0.2).to.be.closeTo(0.1, 1e-3);
Expand All @@ -102,9 +102,9 @@ expect([1, 2, 3]).to.have.ordered.members([1, 2, 3]);

expect("a").to.be.oneOf(["a", "b", "c"]);

expect(x => x).to.change({ val: 0 }, "val");
expect(x => x).to.increase({ val: 0 }, "val");
expect(x => x).to.decrease({ val: 0 }, "val");
expect((x: number) => x).to.change({ val: 0 }, "val");
expect((x: number) => x).to.increase({ val: 0 }, "val");
expect((x: number) => x).to.decrease({ val: 0 }, "val");

/**
* assert API (http://chaijs.com/api/assert/)
Expand All @@ -113,7 +113,7 @@ expect(x => x).to.decrease({ val: 0 }, "val");
// expression
assert("1" === "1", "with message");
assert("1" === "1");
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
assert("1" === "1", 2);

// test standard assert function with overloaded message
Expand All @@ -128,7 +128,7 @@ class SampleClass {
}
var instance = new SampleClass();
assert.instanceOf(instance, SampleClass, "instance check");
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
assert.instanceOf(instance, instance);
assert.notInstanceOf(instance, Array);

Expand Down Expand Up @@ -169,21 +169,21 @@ expect(Promise.resolve(true))
.catch(function() {});

expect(Promise.resolve(true))
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
.to.eventually.be.rejectedWith(Error, 2)
.then(function() {})
.catch(function() {});

expect(Promise.resolve(true))
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
.to.eventually.be.rejectedWith(Error, 'this is a test', {})
.then(function() {})
.catch(function() {});

// tests for chai-subset
expect({}).to.containSubset({});
expect([{}]).to.containSubset([{}]);
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect({}).to.containSubset(0);

// tests for chai-redux-mock-store
Expand All @@ -201,13 +201,15 @@ expect({}).to.contain.dispatchedActions([
]);
expect({}).to.have.dispatchedTypes(["HELLO", "OTHER_ACTION"]);
expect({}).to.contain.dispatchedTypes(["HELLO", "OTHER_ACTION"]);
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect({}).to.have.dispatchedActions(["HELLO", "OTHER_ACTION"]);
// $FlowExpectedError
expect({}).to.have.dispatchedTypes([
// $FlowExpectedError[missing-local-annot]
// $FlowExpectedError[incompatible-call]
action => {
expect(action).to.have.property("type", "HELLO");
},
// $FlowExpectedError[incompatible-call]
{ type: "SOME_TYPE", payload: { name: "John Doe" } }
]);

Expand All @@ -223,5 +225,5 @@ expect('test').to.matchSnapshot();
expect('<div></div>').to.matchSnapshot('html');
expect('<div></div>').to.matchSnapshot('html', true);
expect('<div></div>').to.matchSnapshot('html', true, 'Message');
// $FlowExpectedError
// $FlowExpectedError[incompatible-call]
expect('<div></div>').to.matchSnapshot('html', 'not_boolean', 'Message');
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,7 @@ declare module "lodash-es" {
declare export function before(n: number, fn: Function): Function;
declare export function bind(func: Function, thisArg: any, ...partials: Array<any>): Function;
declare export function bindKey(obj?: ?Object, key?: ?string, ...partials?: Array<?any>): Function;
declare export var curry: Curry;
declare export function curry(func: Function, arity?: number): Function;
declare export var curry: Curry | ((func: Function, arity?: number) => Function);
declare export function curryRight(func: Function, arity?: number): Function;
declare export function debounce<F: Function>(func: F, wait?: number, options?: DebounceOptions): F;
declare export function defer(func: Function, ...args?: Array<any>): TimeoutID;
Expand Down
Loading

0 comments on commit 830640f

Please sign in to comment.