From 973a250339fa5a03908b631167c4cc22be9bbdbd Mon Sep 17 00:00:00 2001 From: Daniel Levitt Date: Fri, 9 Mar 2018 14:00:38 +0000 Subject: [PATCH 01/75] Missing ramda definitions (#1911) * Adding missing definitions * Fix tests and merge def * Tests for lenses * Add test for applyTo Based off of PR https://github.com/flowtype/flow-typed/pull/1871 * startsWith / endsWith tests * Tests for merge and mergeDeep * Fix `o` and add unit tests for other defs * Add currying for Over & Set * Fix tests --- .../flow_v0.62.x-/ramda_v0.x.x.js | 266 ++++++++++++------ .../test_ramda_v0.x.x_functions.js | 39 ++- .../flow_v0.62.x-/test_ramda_v0.x.x_list.js | 14 + .../flow_v0.62.x-/test_ramda_v0.x.x_object.js | 84 +++++- .../test_ramda_v0.x.x_relation.js | 10 + 5 files changed, 311 insertions(+), 102 deletions(-) diff --git a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js index ef111f4da9..3822513a56 100644 --- a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js +++ b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js @@ -500,9 +500,18 @@ declare module ramda { >; declare var split: CurriedFunction2>; declare var test: CurriedFunction2; - declare var startsWith: CurriedFunction2, string, boolean>; + declare var startsWith: CurriedFunction2< + string | Array, + string | Array, + boolean + >; + declare var endsWith: CurriedFunction2< + string | Array, + string | Array, + boolean + >; declare function toLower(a: string): string; - declare function toString(a: any): string; + declare function toString(x: any): string; declare function toUpper(a: string): string; declare function trim(a: string): string; @@ -873,7 +882,10 @@ declare module ramda { ...rest: Array ): (xs: T) => T; - declare function sortWith>(fns: Array<(a: V, b: V) => number>, xs: T): T; + declare function sortWith>( + fns: Array<(a: V, b: V) => number>, + xs: T + ): T; declare function sortWith>( fns: Array<(a: V, b: V) => number>, ...rest: Array @@ -977,10 +989,6 @@ declare module ramda { declare function length(xs: Array): number; - declare function mergeAll( - objs: Array<{ [key: string]: any }> - ): { [key: string]: any }; - declare function reverse | string>(xs: V): V; declare type Reduce = (( @@ -1057,6 +1065,43 @@ declare module ramda { xs: Array ): A; + declare function reduceWhile( + pred: (acc: A, curr: B) => boolean, + ...rest: Array + ): (( + fn: (a: A, b: B) => A, + ...rest: Array + ) => ( + init: A, + ...rest: Array + ) => ( + xs: Array + ) => A & + (( + fn: (a: A, b: B) => A, + ...rest: Array + ) => (init: A, xs: Array) => A)) & + (( + fn: (a: A, b: B) => A, + init: A, + ...rest: Array + ) => (xs: Array) => A) & + ((fn: (a: A, b: B) => A, init: A, xs: Array) => A); + + declare function reduceWhile( + pred: (acc: A, curr: B) => boolean, + fn: (a: A, b: B) => A, + ...rest: Array + ): ((init: A, ...rest: Array) => (xs: Array) => A) & + ((init: A, xs: Array) => A); + + declare function reduceWhile( + fn: (acc: A, curr: B) => boolean, + fn: (a: A, b: B) => A, + init: A, + xs: Array + ): A; + declare function scan( fn: (acc: A, elem: B) => A, ...rest: Array @@ -1217,6 +1262,24 @@ declare module ramda { declare function identical(x: T, ...rest: Array): (y: T) => boolean; declare function identical(x: T, y: T): boolean; + declare function innerJoin( + pred: (a: A, b: B) => boolean, + ...rest: Array + ): ( + a: Array, + ...rest: Array + ) => (b: Array) => Array & ((a: Array, b: Array) => Array); + declare function innerJoin( + pred: (a: A, b: B) => boolean, + a: Array, + ...rest: Array + ): (b: Array) => Array; + declare function innerJoin( + pred: (a: A, b: B) => boolean, + a: Array, + b: Array + ): Array; + declare function intersection(x: Array, y: Array): Array; declare function intersection(x: Array): (y: Array) => Array; @@ -1399,12 +1462,21 @@ declare module ramda { declare function keys(o: Object): Array; - /* TODO - lens - lensIndex - lensPath - lensProp - */ + declare type Lens = (x: T) => V; + + declare function lens( + getter: (s: T) => U, + setter: (a: U, s: T) => V + ): Lens; + declare function lens( + getter: (s: T) => U + ): (setter: (a: U, s: T) => V) => Lens; + + declare function lensIndex(n: number): Lens; + + declare function lensPath(a: Array): Lens; + + declare function lensProp(str: string): Lens; declare function mapObjIndexed( fn: (val: A, key: string, o: Object) => B, @@ -1415,78 +1487,70 @@ declare module ramda { ...args: Array ): (o: { [key: string]: A }) => { [key: string]: B }; - declare function merge(o1: A, ...rest: Array): (o2: B) => A & B; - declare function merge(o1: A, o2: B): A & B; + declare type Merge = ((a: A, b: B) => A & B) & + ((a: A, ...rest: Array) => (b: B) => A & B); + + declare var merge: Merge; declare function mergeAll( os: Array<{ [k: string]: T }> ): { [k: string]: T }; - declare function mergeWith< - T, - S, - R, - A: { [k: string]: T }, - B: { [k: string]: S } - >( - fn: (v1: T, v2: S) => R - ): ((o1: A, ...rest: Array) => (o2: B) => A & B) & - ((o1: A, o2: B) => A & B); - declare function mergeWith< - T, - S, - R, - A: { [k: string]: T }, - B: { [k: string]: S } - >( - fn: (v1: T, v2: S) => R, - o1: A, - o2: B - ): A & B; - declare function mergeWith< - T, - S, - R, - A: { [k: string]: T }, - B: { [k: string]: S } - >( - fn: (v1: T, v2: S) => R, - o1: A, - ...rest: Array - ): (o2: B) => A & B; + declare var mergeDeepLeft: Merge; - declare function mergeWithKey< - T, - S, - R, - A: { [k: string]: T }, - B: { [k: string]: S } - >( - fn: (key: $Keys, v1: T, v2: S) => R - ): ((o1: A, ...rest: Array) => (o2: B) => A & B) & - ((o1: A, o2: B) => A & B); - declare function mergeWithKey< - T, - S, - R, - A: { [k: string]: T }, - B: { [k: string]: S } - >( - fn: (key: $Keys, v1: T, v2: S) => R, - o1: A, - o2: B - ): A & B; - declare function mergeWithKey< - T, - S, - R, + declare var mergeDeepRight: ((a: A, b: B) => B & A) & + ((a: A, ...rest: Array) => (b: B) => B & A); + + declare type MergeWith = (( + fn: (a: T, b: T) => T, + a: A, + b: B + ) => A & B) & + (( + fn: (a: T, b: T) => T, + ...rest: Array + ) => (a: A, ...rest: Array) => (b: B) => A & B) & + (( + fn: (a: T, b: T) => T, + ...rest: Array + ) => (a: A, b: B) => A & B) & + (( + fn: (a: T, b: T) => T, + a: A, + ...rest: Array + ) => (b: B) => A & B); + + declare type MergeWithKey = (< + S: string, A: { [k: string]: T }, - B: { [k: string]: S } + B: { [k: string]: T }, + T >( - fn: (key: $Keys, v1: T, v2: S) => R, - o1: A, - ...rest: Array - ): (o2: B) => A & B; + fn: (s: S, a: T, b: T) => T, + a: A, + b: B + ) => A & B) & + (( + fn: (s: S, a: T, b: T) => T, + ...rest: Array + ) => (a: A, b: B) => A & B) & + (( + fn: (s: S, a: T, b: T) => T, + ...rest: Array + ) => (a: A, ...rest: Array) => (b: B) => A & B) & + (( + fn: (s: S, a: T, b: T) => T, + a: A, + ...rest: Array + ) => (b: B) => A & B); + + declare var mergeDeepWith: MergeWith; + + declare var mergeDeepWithKey: MergeWithKey; + + declare var mergeWith: MergeWith; + + declare var mergeWithKey: MergeWithKey; declare function objOf( key: string, @@ -1495,12 +1559,16 @@ declare module ramda { declare function objOf(key: string, val: T): { [key: string]: T }; declare function omit( - keys: Array<$Keys>, + keys: Array, ...rest: Array ): (val: T) => Object; - declare function omit(keys: Array<$Keys>, val: T): Object; + declare function omit(keys: Array, val: T): Object; - // TODO over + declare function over(lens: Lens, x: (any) => mixed, val: V): U; + declare function over( + lens: Lens, + ...rest: Array + ): ((x: (any) => mixed, ...rest: Array) => (val: V) => U) & ((x: (any) => mixed, val: V) => U); declare function path( p: Array, @@ -1623,7 +1691,11 @@ declare module ramda { o: O ): Array<$ElementType>; - // TODO set + declare function set(lens: Lens, x: T, val: V): U; + declare function set( + lens: Lens, + ...rest: Array + ): ((x: (any) => mixed, ...rest: Array) => (val: V) => U) & ((x: (any) => mixed, val: V) => U); declare function toPairs( o: O @@ -1654,7 +1726,8 @@ declare module ramda { o: $Shape ): boolean; - // TODO view + declare function view(lens: Lens, val: T): V; + declare function view(lens: Lens): (val: T) => V; // *Function declare var __: $npm$ramda$Placeholder; @@ -1689,6 +1762,12 @@ declare module ramda { spec: T ): (...args: A) => NestedObject; + declare function applyTo( + a: A, + ...rest: Array + ): (fn: (x: A) => B) => B; + declare function applyTo(a: A, fn: (x: A) => B): B; + declare function binary( fn: (...args: Array) => T ): (x: any, y: any) => T; @@ -1766,6 +1845,15 @@ declare module ramda { declare function memoize) => B>(fn: T): T; + declare function memoizeWith( + keyFn: (x: A) => string, + ...rest: Array + ): (fn: (x: B) => B) => A; + declare function memoizeWith( + keyFn: (x: A) => string, + fn: (x: B) => B + ): A; + declare function nAry( arity: number, fn: (...args: Array) => T @@ -1773,6 +1861,18 @@ declare module ramda { declare function nthArg(n: number): (...args: Array) => T; + declare var o: (( + fn1: (b: B) => C, + ...rest: void[] + ) => ((fn2: (a: A) => B, ...rest: void[]) => (x: A) => C) & + ((fn2: (a: A) => B, x: A) => C)) & + (( + fn1: (b: B) => C, + fn2: (a: A) => B, + ...rest: void[] + ) => (x: A) => C) & + ((fn1: (b: B) => C, fn2: (a: A) => B, x: A) => C); + declare function of(x: T): Array; declare function once) => B>(fn: T): T; @@ -1973,4 +2073,4 @@ declare module ramda { fn: (x: S) => V, x: T | S ): T | V; -} +} \ No newline at end of file diff --git a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_functions.js b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_functions.js index 73b314234f..03d5818efa 100644 --- a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_functions.js +++ b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_functions.js @@ -53,6 +53,26 @@ const spec = { const getMetrics = _.applySpec(spec); const apspec: $Shape = getMetrics(2, 2); +const applyToResult1 = _.applyTo(5, value => { + (value: number); + // $ExpectError + (value: string); + return String(value) +}); +(applyToResult1: string); +// $ExpectError +(applyToResult1: number); + +const applyToResult2 = _.applyTo(5)(value => { + (value: number); + // $ExpectError + (value: string); + return String(value) +}); +(applyToResult2: string); +// $ExpectError +(applyToResult2: number); + const cmp: (x: Object, y: Object) => number = _.comparator( (a, b) => a.age < b.age ); @@ -287,15 +307,26 @@ const stuffDone: number = doStuff("dd", 1, true, obb); const range = _.juxt([_.toString, Math.min, Math.max]); const ju: Array = range(3, 4, 9, -3); -let count = 0; -const factorial = _.memoize(n => { - count += 1; +let _memoize = 0; +const _memoizeFactorial = _.memoize(n => { + _memoize += 1; return _.product(_.range(1, n + 1)); }); -const mem: number = factorial(5); +const mem: number = _memoizeFactorial(5); + +let _memoizeWith = 0; +const _memoizeWithFactorial = _.memoizeWith(_.identity, n => { + _memoizeWith += 1; + return _.product(_.range(1, n + 1)); +}); +const memWith: number = _memoizeWithFactorial(5); const narg: string | number = _.nthArg(1)(1, "b", "c"); +const nameIs = ({ first, last }) => `The name's ${last}, ${first} ${last}`; +const o1: string = _.o(_.toUpper, nameIs)({ first: "James", last: "Bond" }); +const oNum: number = _.o(_.multiply(10), _.add(10))(-4); + const oof: Array> = _.of([42]); const unap: string = _.unapply(JSON.stringify)(1, 2, 3); diff --git a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_list.js b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_list.js index f704fa00ff..04ef9f6c08 100644 --- a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_list.js +++ b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_list.js @@ -53,6 +53,11 @@ const str: string = "hello world"; const dropxs6: Array = _.dropRepeatsWith(_.eqBy(Math.abs), ns); const dropxs7: Array = _.dropWhile(x => x === 1, ns); + const endsWithxs: boolean = _.endsWith("a")("abc"); + const endsWithxs1: boolean = _.endsWith("b", "abc"); + const endsWithxs2: boolean = _.endsWith(["a"], ["a", "b", "c"]); + const endsWithxs3: boolean = _.endsWith(["b"], ["a", "b", "c"]); + const findxs: ?{ [k: string]: number | string } = _.find( _.propEq("a", 2), os @@ -271,6 +276,10 @@ const str: string = "hello world"; ]; const names1: { [k: string]: Array } = namesByGrade(students); + const isOdd = (acc, x) => x % 2 === 1; + const reduceWhile1: number = _.reduceWhile(isOdd, _.add, 0, [1, 3, 5, 60, 777, 800]); + const reduceWhile2: number = _.reduceWhile(isOdd, _.add, 111, [2, 4, 6]); + const spl: Array = _.split(/\./, "a.b.c.xyz.d"); const spl1: [Array, Array] = _.splitAt(1, [1, 2, 3]); @@ -297,6 +306,11 @@ const str: string = "hello world"; }; const sortxs: Array = _.sort(diff, [4, 2, 7, 5]); + const startsWithxs: boolean = _.startsWith("a")("abc"); + const startsWithxs1: boolean = _.startsWith("b", "abc"); + const startsWithxs2: boolean = _.startsWith(["a"], ["a", "b", "c"]); + const startsWithxs3: boolean = _.startsWith(["b"], ["a", "b", "c"]); + const timesxs: Array = _.times(_.identity, 5); const unf: (x: string) => Array = _.unfold( diff --git a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js index d9c90f5f9e..557f4efc7b 100644 --- a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js +++ b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js @@ -78,18 +78,15 @@ const dissocPathd4: { a: { b: string } } = _.dissocPath(["a", "c"])({ a: { b: 1, c: 2 } }); -describe('#eqProps', () => { - const o1 = { a: 1, b: 2, c: 3, d: 4 }; - const o2 = { a: 10, b: 20, c: 3, d: 40 }; - it('should do basic type checking', () => { - const ep: boolean = _.eqProps("a", o1, o2); - }) +const o1 = { a: 1, b: 2, c: 3, d: 4 }; +const o2 = { a: 10, b: 20, c: 3, d: 40 }; - // curried versions - const ep: boolean = _.eqProps("a")(o1, o2); - const ep2: boolean = _.eqProps("c", o1)(o2); -}) +const ep: boolean = _.eqProps("a", o1, o2); + +// curried versions +const epCurr: boolean = _.eqProps("a")(o1, o2); +const ep2: boolean = _.eqProps("c", o1)(o2); const evolved1 = _.evolve( { @@ -188,16 +185,44 @@ const mwithK = _.mergeWithKey( ); const propB1: boolean = mwithK.b; +const mDwith = _.mergeDeepWith( + _.concat, + { a: true, values: [10, 20] }, + { b: true, values: [15, 35] } +); +const propmDwithB: boolean = mDwith.b; + +const concatValues = (k, l, r) => k == 'values' ? _.concat(l, r) : r +const mDwithKey = _.mergeDeepWithKey( + concatValues, + { a: true, c: { thing: 'foo', values: [10, 20] }}, + { b: true, c: { thing: 'bar', values: [15, 35] }} +); +const propmDwithKeyB: boolean = mDwithKey.b; + +const mDLeft = _.mergeDeepLeft( + { a: true, values: [10, 20] }, + { b: true, values: [15, 35] } +); +const propB2: boolean = mDLeft.a; +const propB3: boolean = mDLeft.b; +const propB4: 10 = mDLeft.values[0]; + +const mDRight = _.mergeDeepRight( + { a: true, values: [10, 20] }, + { b: true, values: [15, 35] } +); +const propB5: boolean = mDRight.a; +const propB6: boolean = mDRight.b; +const propB7: 15 = mDRight.values[0]; + const objA = _.objOf("a", false); //$ExpectError const propAA: number = objA.a; -//$ExpectError const om: Object = _.omit(["a", "d", "h"], { a: 1, b: 2, c: 3, d: 4 }); - const omap1 = _.omit(["a", "d", "h"], { a: 1, b: 2, c: 3, d: 4, h: 7 }); -//$ExpectError -const omap2 = _.omit(["a", "d", "h"], { a: 1, b: 2, c: 3, d: 4 }); +const omap2 = _.omit(["a", "d", "h"])({ a: 1, b: 2, c: 3, d: 4 }); const path1: Object | number = _.path(["a", "b"], { a: { b: 2 } }); const path2: Object | number = _.path(["a", 1], { a: { "1": 2 } }); @@ -289,7 +314,7 @@ const pred = _.where({ b: _.complement(_.equals("bar")), c: (c: Object) => !!c, x: _.gt(10), - y: _.lt(20) + y: _.lt(20), }); const w: boolean = pred({ a: "foo", b: "xxx", c: {}, x: 11, y: 19 }); @@ -297,3 +322,32 @@ const w: boolean = pred({ a: "foo", b: "xxx", c: {}, x: 11, y: 19 }); const pred1 = _.whereEq({ a: 1, b: 2 }); const win: boolean = pred1({ a: 1, d: 1 }); + +const xLens = _.lens(_.prop('x'), _.assoc('x')); +const xLensPath = _.lensPath(['y', 0, 'y']); +const xLensIndex = _.lensIndex(0); +const xLensProp = _.lensProp('x'); + +const dataObj = {x: 5, y: [{y: 2, z: 3}, {y: 4, z: 5}]}; +const dataArr = ['a', 'b', 'c']; + +const xLensView: number = _.view(xLens, dataObj); +const xLensSet: Array<{ [k: string]: * }> = _.set(xLens, 4, dataObj); +const xLensOver: Array<{ [k: string]: * }> = _.over(xLens, _.negate, dataObj); + +const xLensPathView: number = _.view(xLensPath, dataObj); +const xLensPathSet: Array<{ [k: string]: * }> = _.set(xLensPath, 4, dataObj); +const xLensPathSetCurr: Array<{ [k: string]: * }> = _.set(xLensPath, 4)(dataObj); +const xLensPathOver: Array<{ [k: string]: * }> = _.over(xLensPath, _.negate, dataObj); +const xLensPathOverCurr: Array<{ [k: string]: * }> = _.over(xLensPath)(_.negate)(dataObj); + +const xLensIndexView: number = _.view(xLensIndex, dataArr); +const xLensIndexSet: Array = _.set(xLensIndex, "test", dataArr); +const xLensIndexSetCurr: Array = _.set(xLensIndex)("test", dataArr); +const xLensIndexOver: Array = _.over(xLensIndex, _.concat("test"), dataArr); +const xLensIndexOverCurr: Array = _.over(xLensIndex, _.concat("test"))(dataArr); + +const xLensPropView: number = _.view(xLensProp, dataObj); +const xLensPropSet: Array<{ [k: string]: * }> = _.set(xLensProp, 4, dataObj); +const xLensPropOver: Array<{ [k: string]: * }> = _.over(xLensProp, _.negate, dataObj); +const xLensPropOverCurr: Array<{ [k: string]: * }> = _.over(xLensProp)(_.negate, dataObj); diff --git a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_relation.js b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_relation.js index e730999747..3c5f5467fd 100644 --- a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_relation.js +++ b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_relation.js @@ -46,6 +46,16 @@ const _minBy: number = _.minBy(Math.abs, 2, 1); const _identical: boolean = _.identical(2, 1); +const _innerJoin: Array<{ [k: string]: mixed }> = _.innerJoin( + (record, id) => record.id === id, + [{id: 824, name: 'Richie Furay'}, + {id: 956, name: 'Dewey Martin'}, + {id: 313, name: 'Bruce Palmer'}, + {id: 456, name: 'Stephen Stills'}, + {id: 177, name: 'Neil Young'}], + [177, 456, 999] +); + const inters: Array = _.intersection(ns, ns); const interBy: Array = _.intersectionWith(_.eqBy(Math.abs), ns, ns); From 16c4c9e5dd4579853b2046f36ee892a0531403cf Mon Sep 17 00:00:00 2001 From: Alessio Prestileo Date: Fri, 9 Mar 2018 15:44:39 +0100 Subject: [PATCH 02/75] Adds definitions for package redux-rsaa-middleware. (#1931) * Adds definitions for package redux-rsaa-middleware. * Adds testing. * Replaces import statement with mock types. Uses module.exports for exporting variable. * Change back to export var My bad... --- .../redux-rsaa-middleware_v1.x.x.js | 41 +++++++++++++++ .../test_redux-rsaa-middleware_v1.x.x.js | 51 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/redux-rsaa-middleware_v1.x.x.js create mode 100644 definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/test_redux-rsaa-middleware_v1.x.x.js diff --git a/definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/redux-rsaa-middleware_v1.x.x.js b/definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/redux-rsaa-middleware_v1.x.x.js new file mode 100644 index 0000000000..4c14ba7157 --- /dev/null +++ b/definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/redux-rsaa-middleware_v1.x.x.js @@ -0,0 +1,41 @@ +declare module 'redux-rsaa-middleware' { + declare type DispatchAPI = (action: A) => A; + + declare type Dispatch }> = DispatchAPI; + + declare type MiddlewareAPI> = { + dispatch: D; + getState(): S; + }; + + declare type Middleware> = + (api: MiddlewareAPI) => + (next: D) => D; + + declare type Action = { + type: string, + payload: Object, + }; + + declare type State = Object; + + declare export var RSAAMiddleware : Middleware>; + + declare export type RSAAPayload = { + method?: string, + path?: string, + query?: string, + error?: Object, + errorTime?: string, + response?: Object, + failureAction?: RSAAAction, + successAction?: RSAAAction, + startedSendingAction?: RSAAAction, + finishedSendingAction?: RSAAAction, + }; + + declare export type RSAAAction = { + type: string, + payload: RSAAPayload, + }; +} diff --git a/definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/test_redux-rsaa-middleware_v1.x.x.js b/definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/test_redux-rsaa-middleware_v1.x.x.js new file mode 100644 index 0000000000..4f664b4763 --- /dev/null +++ b/definitions/npm/redux-rsaa-middleware_v1.x.x/flow_v0.66.x-/test_redux-rsaa-middleware_v1.x.x.js @@ -0,0 +1,51 @@ +// @flow + +import type { RSAAAction } from 'redux-rsaa-middleware'; + +const newActionValid : RSAAAction = { + type: 'RSAA', + payload: { + method: 'GET', + path: 'https://myPath.com/resource', + startedSendingAction: { + type: 'STARTED_FETCHING_RESOURCE', + payload: {}, + }, + finishedSendingAction: { + type: 'FINISHED_FETCHING_RESOURCE', + payload: {}, + }, + successAction: { + type: 'UPDATE_USERS_WITH_RESOURCE', + payload: {}, + }, + }, +}; + +const newActionInvalid : RSAAAction = { + // $ExpectError - incompatible property type + type: null, + payload: { + // $ExpectError - incompatible property type + method: null, + // $ExpectError - incompatible property type + path: null, + // $ExpectError - incompatible property type + query: null, + startedSendingAction: { + type: 'STARTED_FETCHING_RESOURCE', + // $ExpectError - incompatible property type + payload: null, + }, + finishedSendingAction: { + type: 'FINISHED_FETCHING_RESOURCE', + payload: {}, + }, + successAction: { + type: 'UPDATE_USERS_WITH_RESOURCE', + payload: {}, + }, + // $ExpectError - incompatible property type + failureAction: null, + }, +}; \ No newline at end of file From 9abfbf51f37d693c446bb21a98b4cad139fa81a4 Mon Sep 17 00:00:00 2001 From: Jeff Allen Date: Fri, 9 Mar 2018 14:09:22 -0500 Subject: [PATCH 03/75] Spelling error on "internal" (#1940) Was initially spelled "intenral"! --- definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js b/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js index e12d1ecd10..387d6707d8 100644 --- a/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js +++ b/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js @@ -203,7 +203,7 @@ declare module "knex" { detail: string, hint?: string, position?: any, - intenralPosition?: any, + internalPosition?: any, internalQuery?: any, where?: any, schema: string, From e1a981be2f28c70e0a7c52c858faf965670d084d Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Sat, 10 Mar 2018 02:31:49 +0300 Subject: [PATCH 04/75] Add errors to rxjs (#1939) --- .../rxjs_v5.0.x/flow_v0.34.x-/rxjs_v5.0.x.js | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/definitions/npm/rxjs_v5.0.x/flow_v0.34.x-/rxjs_v5.0.x.js b/definitions/npm/rxjs_v5.0.x/flow_v0.34.x-/rxjs_v5.0.x.js index dd7617d271..43ae0fc68e 100644 --- a/definitions/npm/rxjs_v5.0.x/flow_v0.34.x-/rxjs_v5.0.x.js +++ b/definitions/npm/rxjs_v5.0.x/flow_v0.34.x-/rxjs_v5.0.x.js @@ -1548,7 +1548,11 @@ declare class rxjs$SchedulerClass { ): rxjs$Subscription; } +declare class rxjs$ArgumentOutOfRangeError extends Error {} +declare class rxjs$EmptyError extends Error {} +declare class rxjs$ObjectUnsubscribedError extends Error {} declare class rxjs$TimeoutError extends Error {} +declare class rxjs$UnsubscriptionError extends Error {} declare module "rxjs" { declare module.exports: { @@ -1567,7 +1571,11 @@ declare module "rxjs" { async: rxjs$SchedulerClass }, Subscription: typeof rxjs$Subscription, - TimeoutError: typeof rxjs$TimeoutError + ArgumentOutOfRangeError: typeof rxjs$ArgumentOutOfRangeError, + EmptyError: typeof rxjs$EmptyError, + ObjectUnsubscribedError: typeof rxjs$ObjectUnsubscribedError, + TimeoutError: typeof rxjs$TimeoutError, + UnsubscriptionError: typeof rxjs$UnsubscriptionError, }; } @@ -1619,3 +1627,33 @@ declare module "rxjs/testing/TestScheduler" { TestScheduler: typeof rxjs$SchedulerClass }; } + +declare module "rxjs/util/ArgumentOutOfRangeError" { + declare module.exports: { + ArgumentOutOfRangeError: typeof rxjs$ArgumentOutOfRangeError, + }; +} + +declare module "rxjs/util/EmptyError" { + declare module.exports: { + EmptyError: typeof rxjs$EmptyError, + }; +} + +declare module "rxjs/util/ObjectUnsubscribedError" { + declare module.exports: { + ObjectUnsubscribedError: typeof rxjs$ObjectUnsubscribedError, + }; +} + +declare module "rxjs/util/TimeoutError" { + declare module.exports: { + TimeoutError: typeof rxjs$TimeoutError, + }; +} + +declare module "rxjs/util/UnsubscriptionError" { + declare module.exports: { + UnsubscriptionError: typeof rxjs$UnsubscriptionError, + }; +} From 3f9be5047cb0b21dfa63e071f81b877235dc3cfb Mon Sep 17 00:00:00 2001 From: Mario Estrada Date: Fri, 9 Mar 2018 20:37:38 -0800 Subject: [PATCH 05/75] [new-def] Adds definitions and tests to `ua-parser-js` (#1944) --- .../flow_v0.42.x-/ua-parser-js_v0.7.x.js | 55 +++++++++++++++++++ .../test_ua-parser-js_v0.7.x.js | 50 +++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 definitions/npm/ua-parser-js_v0.7.x/flow_v0.42.x-/ua-parser-js_v0.7.x.js create mode 100644 definitions/npm/ua-parser-js_v0.7.x/test_ua-parser-js_v0.7.x.js diff --git a/definitions/npm/ua-parser-js_v0.7.x/flow_v0.42.x-/ua-parser-js_v0.7.x.js b/definitions/npm/ua-parser-js_v0.7.x/flow_v0.42.x-/ua-parser-js_v0.7.x.js new file mode 100644 index 0000000000..868b2e0a15 --- /dev/null +++ b/definitions/npm/ua-parser-js_v0.7.x/flow_v0.42.x-/ua-parser-js_v0.7.x.js @@ -0,0 +1,55 @@ +declare module 'ua-parser-js' { + declare type UABrowser = { + name: string, + version: string, + }; + + declare type UACpu = { + architecture: string, + }; + + declare type UADevice = { + model: string, + type: + | 'console' + | 'mobile' + | 'tablet' + | 'smarttv' + | 'wearable' + | 'embedded', + vendor: string, + }; + + declare type UAEngine = { + name: string, + version: string, + }; + + declare type UAOs = { + name: string, + version: string, + }; + + declare type UAResult = { + browser: UABrowser, + cpu: UACpu, + device: UADevice, + engine: UAEngine, + os: UAOs, + ua: string, + }; + + declare class UAParser { + constructor(): UAParser; + getBrowser(): UABrowser; + getCPU(): UACpu; + getDevice(): UADevice; + getEngine(): UAEngine; + getOS(): UAOs; + getResult(): UAResult; + getUA(): string; + setUA(ua: string): UAParser; + } + + declare export default typeof UAParser; +} diff --git a/definitions/npm/ua-parser-js_v0.7.x/test_ua-parser-js_v0.7.x.js b/definitions/npm/ua-parser-js_v0.7.x/test_ua-parser-js_v0.7.x.js new file mode 100644 index 0000000000..30774b202a --- /dev/null +++ b/definitions/npm/ua-parser-js_v0.7.x/test_ua-parser-js_v0.7.x.js @@ -0,0 +1,50 @@ +// @flow + +import UAParser from 'ua-parser-js'; + +const parser = new UAParser(); +(parser: UAParser); + +parser.setUA('MOCK UA'); +// $ExpectError +parser.setUA(123); + +(parser.getBrowser(): { + name: string, + version: string, +}); + +(parser.getCPU(): { + architecture: string, +}); + +const device = parser.getDevice(); +(device.model: string); +(device.vendor: string); +(device.type: string); + +(parser.getEngine(): { + name: string, + version: string, +}); + +const parserResult = parser.getResult(); +// $ExpectError +(parserResult.browser: null); +// $ExpectError +(parserResult.cpu: null); +// $ExpectError +(parserResult.device: null); +// $ExpectError +(parserResult.engine: null); +// $ExpectError +(parserResult.os: null); +// $ExpectError +(parserResult.ua: null); + +(parser.getOS(): { + name: string, + version: string, +}); + +(parser.getUA(): string); From 76dc0540fb20729269ea3e396810ee42930f1dd6 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Sat, 10 Mar 2018 18:16:33 +0300 Subject: [PATCH 06/75] Add suppressUnhandledRejections (#1945) --- .../npm/bluebird_v3.x.x/flow_v0.47.x-/bluebird_v3.x.x.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/definitions/npm/bluebird_v3.x.x/flow_v0.47.x-/bluebird_v3.x.x.js b/definitions/npm/bluebird_v3.x.x/flow_v0.47.x-/bluebird_v3.x.x.js index fe6ee3c8b0..1171a2f855 100644 --- a/definitions/npm/bluebird_v3.x.x/flow_v0.47.x-/bluebird_v3.x.x.js +++ b/definitions/npm/bluebird_v3.x.x/flow_v0.47.x-/bluebird_v3.x.x.js @@ -297,6 +297,8 @@ declare class Bluebird$Promise<+R> extends Promise { disposable: Bluebird$Disposable, handler: (value: T) => $Promisable ): Bluebird$Promise; + + suppressUnhandledRejections(): void; } declare class Bluebird$Defer { From 8d6057d0b1b00cde184c7a6d274ef66668a7416b Mon Sep 17 00:00:00 2001 From: Craig Bruce Date: Sun, 11 Mar 2018 05:49:19 +1100 Subject: [PATCH 07/75] Add Chromecast Receiver CAF Framework typedefs (#1937) * Add caf-receiver definitions * Move definitions to correct folder. Add at least one test for each module. * Fix flow errors and add new message types * Specify flow lower bound version * Moved to definitions/browser as there will never be an npm package for this library - it is a script reference only. --- .../chromecast-caf-receiver_v3.x.x.js | 3038 +++++++++++++++++ .../test_chromecast-caf-receiver_v3.x.x.js | 52 + 2 files changed, 3090 insertions(+) create mode 100644 definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js create mode 100644 definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js diff --git a/definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js b/definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js new file mode 100644 index 0000000000..1563325725 --- /dev/null +++ b/definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js @@ -0,0 +1,3038 @@ +// @flow + +declare module 'cast' { + import type { PlayerDataChangedEvent } from 'cast.framework.ui'; + import type { NetworkRequestInfo } from 'cast.framework'; + + declare export type EventHandler = (event: Event) => void; + declare export type PlayerDataChangedEventHandler = ( + event: PlayerDataChangedEvent, + ) => void; + declare export type RequestHandler = (request: NetworkRequestInfo) => void; + declare export type BinaryHandler = (data: Uint8Array) => Uint8Array; +} +declare module 'cast.framework' { + import type { + Track, + TextTrackStyle, + QueueItem, + QueueData, + LoadRequestData, + Break, + } from 'cast.framework.messages'; + + import type { BreakManager } from 'cast.framework.breaks'; + import type { + LiveSeekableRange, + PlayerState, + MediaInformation, + PlayerStringId, + } from 'cast.framework.messages'; + + /** + * Manages text tracks. + */ + declare export class TextTracksManager { + constructor(params: mixed): TextTracksManager; + + /** + * Adds text tracks to the list. + */ + addTracks(tracks: Array): void; + + /** + * Creates a text track. + */ + createTrack(): Track; + + /** + * Gets all active text ids. + */ + getActiveIds(): Array; + + /** + * Gets all active text tracks. + */ + getActiveTracks(): Array; + + /** + * Returns the current text track style. + */ + getTextTracksStyle(): TextTrackStyle; + + /** + * Gets text track by id. + */ + getTrackById(id: number): Track; + + /** + * Returns all text tracks. + */ + getTracks(): Array; + + /** + * Gets text tracks by language. + */ + getTracksByLanguage(language: string): Array; + + /** + * Sets text tracks to be active by id. + */ + setActiveByIds(newIds: Array): void; + + /** + * Sets text tracks to be active by language. + */ + setActiveByLanguage(language: string): void; + + /** + * Sets text track style. + */ + setTextTrackStyle(style: TextTrackStyle): void; + } + + /** + * QueueManager exposes several queue manipulation APIs to developers. + */ + declare export class QueueManager { + constructor(params: mixed): QueueManager; + + /** + * Returns the current queue item. + */ + getCurrentItem(): QueueItem; + + /** + * Returns the index of the current queue item. + */ + getCurrentItemIndex(): number; + + /** + * Returns the queue items. + */ + getItems(): Array; + + /** + * Inserts items into the queue. + */ + insertItems(items: Array, insertBefore?: number): void; + + /** + * Removes items from the queue. + */ + removeItems(itemIds: Array): void; + + /** + * Sets whether to limit the number of queue items to be reported in Media Status (default is true). + */ + setQueueStatusLimit(limitQueueItemsInStatus: boolean): void; + + /** + * Updates existing queue items by matching itemId. + */ + updateItems(items: Array): void; + } + + /** + * Base implementation of a queue. + */ + declare export class QueueBase { + /** + * Fetches a window of items using the specified item id as reference; called by the receiver MediaManager when it needs more queue items, often as a request from senders. If only one of nextCount and prevCount is non-zero, fetchItems should only return items after or before the reference item; if both nextCount and prevCount are non-zero, a window of items including the reference item should be returned. + */ + fetchItems( + itemId: number, + nextCount: number, + prevCount: number, + ): Array | Promise>; + + /** + * Initializes the queue with the requestData. This is called when a new LOAD request comes in to the receiver. If this returns or resolves to null, our default queueing implementation will create a queue based on queueData.items or the single media in the load request data. + */ + initialize(requestData: LoadRequestData): QueueData | Promise; + + /** + * Returns next items after the reference item, often the end of the current queue, called by the receiver MediaManager. + */ + nextItems(itemId?: number): Array | Promise>; + + /** + * Sets the current item with the itemId; called by the receiver MediaManager when it changes the current playing item. + */ + onCurrentItemIdChanged(itemId: number): void; + + /** + * A callback for informing the following items have been inserted into the receiver queue in this session. A cloud based implementation can optionally choose to update its queue based on the new information. + */ + onItemsInserted(items: Array, insertBefore?: number): void; + + /** + * A callback for informing the following items have been removed from the receiver queue in this session. A cloud based implementation can optionally choose to update its queue based on the new information. + */ + onItemsRemoved(itemIds: Array): void; + + /** + * Returns previous items before the reference item, often at the beginning of the queue, called by the receiver MediaManager. + */ + prevItems(itemId?: number): Array | Promise>; + + /** + * Shuffles the queue and returns new queue items. Returns null if the operation is not supported. + */ + shuffle(): Array | Promise>; + } + + /** + * Controls and monitors media playback. + */ + declare export class PlayerManager { + constructor(params: mixed): PlayerManager; + + /** + * Adds an event listener for player event. + */ + // addEventListener: (eventType: EventType | Array, eventListener: EventHandler); + + /** + * Sends a media status message to all senders (broadcast). Applications use this to send a custom state change. + */ + broadcastStatus( + includeMedia?: boolean, + requestId?: number, + customData?: mixed, + includeQueueItems?: boolean, + ): void; + + /** + * + */ + getAudioTracksManager(): AudioTracksManager; + + /** + * Returns current time in sec in currently-playing break clip. + */ + getBreakClipCurrentTimeSec(): number; + + /** + * Returns duration in sec of currently-playing break clip. + */ + getBreakClipDurationSec(): number; + + /** + * Obtain the breaks (Ads) manager. + */ + getBreakManager(): BreakManager; + + /** + * Returns list of breaks. + */ + getBreaks(): Array; + + /** + * Gets current time in sec of current media. + */ + getCurrentTimeSec(): number; + + /** + * Gets duration in sec of currently playing media. + */ + getDurationSec(): number; + + /** + * Returns live seekable range with start and end time in seconds. The values are media time based. + */ + getLiveSeekableRange(): LiveSeekableRange; + + /** + * Gets media information of current media. + */ + getMediaInformation(): MediaInformation; + + /** + * Returns playback configuration. + */ + getPlaybackConfig(): PlaybackConfig; + + /** + * Returns current playback rate. + */ + getPlaybackRate(): number; + + /** + * Gets player state. + */ + getPlayerState(): PlayerState; + + /** + * Get the preferred playback rate. (Can be used on shutdown event to save latest preferred playback rate to a persistent storage, so it can be used in next session in the cast options). + */ + getPreferredPlaybackRate(): number; + + /** + * Get the preferred text track language. + */ + getPreferredTextLanguage(): string; + + /** + * Obtain QueueManager API. + */ + getQueueManager(): QueueManager; + + /** + * + */ + getTextTracksManager(): TextTracksManager; + + /** + * Loads media. + */ + load(loadRequest: LoadRequestData): Promise; + + /** + * Pauses currently playing media. + */ + pause(): void; + + /** + * Plays currently paused media. + */ + play(): void; + + /** + * Requests a text string to be played back locally on the receiver device. + */ + playString( + stringId: PlayStringId, + args?: Array, + ): Promise; + + /** + * Request Google Assistant to refresh the credentials. Only works if the original credentials came from the assistant. + */ + refreshCredentials(): Promise; + + /** + * Removes the event listener added for given player event. If event listener is not added, it will be ignored. + */ + removeEventListener( + eventType: EventType | Array, + eventListener: EventHandler, + ): void; + + /** + * Seeks in current media. + */ + seek(seekTime: number): void; + + /** + * Sends an error to a specific sender + */ + sendError( + senderId: string, + requestId: number, + type: ErrorType, + reason?: ErrorReason, + customData?: mixed, + ): void; + + /** + * Send local media request. + */ + sendLocalMediaRequest(request: RequestData): void; + + /** + * Sends a media status message to a specific sender. + */ + sendStatus( + senderId: string, + requestId: number, + includeMedia?: boolean, + customData?: mixed, + includeQueueItems?: boolean, + ): void; + + /** + * Sets the IDLE reason. This allows applications that want to force the IDLE state to indicate the reason that made the player going to IDLE state (a custom error, for example). The idle reason will be sent in the next status message. NOTE: Most applications do not need to set this value, it is only needed if they want to make the player go to IDLE in special circumstances and the default idleReason does not reflect their intended behavior. + */ + setIdleReason(idleReason: IdleReason): void; + + /** + * Sets MediaElement to use. If Promise of MediaElement is set, media begins playback after Promise is resolved. + */ + setMediaElement(mediaElement: HTMLMediaElement): void; + + /** + * Sets media information. + */ + setMediaInformation( + mediaInformation: MediaInformation, + opt_broadcast?: boolean, + ): void; + + /** + * Sets a handler to return or modify PlaybackConfig, for a specific load request. The handler paramaters are the load request data and default playback config for the receiver (provided in the context options). The handler should returns a modified playback config, or null to prevent the media from playing. The return value can be a promise to allow waiting for data from the server. + */ + setMediaPlaybackInfoHandler( + handler: ( + loadRequestData: LoadRequestData, + playbackConfig: PlaybackConfig, + ) => void, + ): void; + + /** + * Sets a handler to return the media url for a load request. This handler can be used to avoid having the media content url published as part of the media status. By default the media contentId is used as the content url. + */ + setMediaUrlResolver( + resolver: (loadRequestData: LoadRequestData | null) => void, + ): void; + + /** + * Provide an interceptor of incoming and outgoing messages. The interceptor can update the request data, and return updated data, a promise of updated data if need to get more data from the server, or null if the request should not be handled. Note that if load message interceptor is provided, and no interceptor is provided for preload - the load interceptor will be called for preload messages. + */ + setMessageInterceptor( + type: MessageType, + interceptor: (requestData: RequestData | null) => void, + ): void; + + /** + * Sets playback configuration on the PlayerManager. + */ + setPlaybackConfig(playbackConfig: PlaybackConfig): void; + + /** + * Set the preferred playback rate for follow up load or media items. The preferred playback rate will be updated automatically to the latest playback rate that was provided by a load request or explicit set of playback rate. + */ + setPreferredPlaybackRate(preferredPlaybackRate: number): void; + + /** + * Set the preferred text track language. The preferred text track language will be updated automatically to the latest enabled language by a load request or explicit change to text tracks. (Should be called only in idle state, and Will only apply to next loaded media). + */ + setPreferredTextLanguage(preferredTextLanguage: string): void; + + /** + * Stops currently playing media. + */ + stop(): void; + } + + /** + * Configuration to customize playback behavior. + */ + declare export class PlaybackConfig { + /** + * Duration of buffered media in seconds to start buffering. + */ + autoPauseDuration?: number; + + /** + * Duration of buffered media in seconds to start/resume playback after auto-paused due to buffering. + */ + autoResumeDuration?: number; + + /** + * Minimum number of buffered segments to start/resume playback. + */ + autoResumeNumberOfSegments?: number; + + /** + * A function to customize request to get a caption segment. + */ + captionsRequestHandler?: RequestHandler; + + /** + * Initial bandwidth in bits in per second. + */ + initialBandwidth?: number; + + /** + * Custom license data. + */ + licenseCustomData?: string; + + /** + * Handler to process license data. The handler is passed the license data, and returns the modified license data. + */ + licenseHandler?: BinaryHandler; + + /** + * A function to customize request to get a license. + */ + licenseRequestHandler?: RequestHandler; + + /** + * Url for acquiring the license. + */ + licenseUrl?: string; + + /** + * Handler to process manifest data. The handler is passed the manifest, and returns the modified manifest. + */ + manifestHandler?: (manifest: string) => string; + + /** + * A function to customize request to get a manifest. + */ + manifestRequestHandler?: RequestHandler; + + /** + * Preferred protection system to use for decrypting content. + */ + protectionSystem: ContentProtection; + + /** + * Handler to process segment data. The handler is passed the segment data, and returns the modified segment data. + */ + segmentHandler?: BinaryHandler; + + /** + * A function to customize request information to get a media segment. + */ + segmentRequestHandler?: RequestHandler; + + /** + * Maximum number of times to retry a network request for a segment. + */ + segmentRequestRetryLimit?: number; + } + /** + * HTTP(s) Request/Response information. + */ + declare export class NetworkRequestInfo { + /** + * The content of the request. Can be used to modify license request body. + */ + content: Uint8Array | null; + + /** + * An object containing properties that you would like to send in the header. + */ + headers: mixed; + + /** + * The URL requested. + */ + url: string | null; + + /** + * Indicates whether CORS Access-Control requests should be made using credentials such as cookies or authorization headers. + */ + withCredentials: boolean; + } + /** Cast receiver context options. All options are optionals. */ + declare export class CastReceiverOptions { + /** + * Optional map of custom messages namespaces to initialize and their types. + * Custom messages namespaces need to be initiated before the application started, + * so it is best to provide the namespaces in the receiver options. + * (The default type of a message bus is JSON, if not provided here). + */ + customNamespaces?: mixed; + + /** + * Sender id used for local requests. Default value is 'local'. + */ + localSenderId: string; + + /** + * Maximum time in seconds before closing an idle sender connection. + * Setting this value enables a heartbeat message to keep the connection alive. + * Used to detect unresponsive senders faster than typical TCP timeouts. + * The minimum value is 5 seconds, there is no upper bound enforced but practically it's minutes before platform TCP timeouts come into play. + * Default value is 10 seconds. + */ + maxInactivity: number; + + /** + * Optional media element to play content with. Default behavior is to use the first found media element in the page. + */ + mediaElement: HTMLMediaElement; + + /** + * Optional playback configuration. + */ + playbackConfig: PlaybackConfig; + + /** + * If this is true, the watched client stitching break will also be played. + */ + playWatchedBreak: boolean; + + /** + * Preferred value for player playback rate. It is used if playback rate value is not provided in the load request. + */ + preferredPlaybackRate: number; + + /** + * Preferred text track language. It is used if no active track is provided in the load request. + */ + preferredTextLanguage: string; + + /** + * Optional queue implementation. + */ + queue: QueueBase; + + /** + * Text that represents the application status. + * It should meet internationalization rules as may be displayed by the sender application. + */ + statusText: string; + + /** + * A bitmask of media commands supported by the application. + * LOAD, PLAY, STOP, GET_STATUS must always be supported. + * If this value is not provided, then PAUSE, SEEK, STREAM_VOLUME, STREAM_MUTE are assumed to be supported too. + */ + supportedCommands: number; + + /** + * Indicate that MPL should be used for DASH content. + */ + useLegacyDashSupport: boolean; + + /** + * An integer used as an internal version number. + * This number is used only to distinguish between receiver releases and higher numbers do not necessarily have to represent newer releases. + */ + versionCode: number; + } + + /** Manages loading of underlying libraries and initializes underlying cast receiver SDK. */ + declare export class CastReceiverContext { + constructor(params: mixed): CastReceiverContext; + + /** Returns the CastReceiverContext singleton instance. */ + static getInstance(): CastReceiverContext; + + /** + * Sets message listener on custom message channel. + */ + addCustomMessageListener(namespace: string, listener: EventHandler): void; + + /** + * Add listener to cast system events. + */ + addEventListener(type: EventType, handler: EventHandler): void; + + /** + * Checks if the given media params of video or audio streams are supported by the platform. + */ + canDisplayType( + mimeType: string, + codecs?: string, + width?: number, + height?: number, + framerate?: number, + ): boolean; + + /** + * Provides application information once the system is ready, otherwise it will be null. + */ + getApplicationData(): ApplicationData; + + /** + * Provides device capabilities information once the system is ready, otherwise it will be null. + * If an empty object is returned, the device does not expose any capabilities information. + */ + getDeviceCapabilities(): mixed; + + /** + * Get Player instance that can control and monitor media playback. + */ + getPlayerManager(): PlayerManager; + + /** + * Get a sender by sender id + */ + getSender(senderId: string): Sender; + + /** + * Gets a list of currently-connected senders. + */ + getSenders(): Array; + + /** + * Reports if the cast application's HDMI input is in standby. + */ + getStandbyState(): StandbyState; + + /** + * Provides application information about the system state. + */ + getSystemState(): SystemState; + + /** + * Reports if the cast application is the HDMI active input. + */ + getVisibilityState(): VisibilityState; + + /** + * When the application calls start, the system will send the ready event to indicate + * that the application information is ready and the application can send messages as soon as there is one sender connected. + */ + isSystemReady(): boolean; + + /** + * Start loading player js. This can be used to start loading the players js code in early stage of starting the receiver before calling start. + * This function is a no-op if players were already loaded (start was called). + */ + loadPlayerLibraries(useLegacyDashSupport?: boolean): void; + + /** + * Remove a message listener on custom message channel. + */ + removeCustomMessageListener( + namespace: string, + listener: EventHandler, + ): void; + + /** + * Remove listener to cast system events. + */ + removeEventListener(type: EventType, handler: EventHandler): void; + + /** + * Sends a message to a specific sender. + */ + sendCustomMessage( + namespace: string, + senderId: string, + message: mixed, + ): void; + + /** + * This function should be called in response to the feedbackstarted event if the application + * add debug state information to log in the feedback report. + * It takes in a parameter ‘message’ that is a string that represents the debug information that the application wants to log. + */ + sendFeedbackMessage(feedbackMessage: string): void; + + /** + * Sets the application state. The application should call this when its state changes. + * If undefined or set to an empty string, the value of the Application Name established during application + * registration is used for the application state by default. + */ + setApplicationState(statusText: string): void; + + /** + * Sets the receiver inactivity timeout. + * It is recommended to set the maximum inactivity value when calling Start and not changing it. + * This API is just provided for development/debugging purposes. + */ + setInactivityTimeout(maxInactivity: number): void; + + /** + * Sets the log verbosity level. + */ + setLoggerLevel(level: LoggerLevel): void; + + /** + * Initializes system manager and media manager, so that receiver app can receive requests from senders. + */ + start(options: CastReceiverOptions): CastReceiverContext; + + /** + * Shutdown receiver application. + */ + stop(): void; + } + + /** Manages audio tracks. */ + declare export class AudioTracksManager { + constructor(params: mixed): AudioTracksManager; + getActiveId(): number | null; + getActiveTrack(): Track | null; + getTrackById(id: number): Track | null; + getTracks(): Array; + getTracksByLanguage(language: string): Array; + setActiveById(id: number): void; + setActiveByLanguage(language: string): void; + } +} +declare module 'cast.framework.system' { + /** + * Event dispatched by @see{@link CastReceiverManager} when the visibility of the application changes (HDMI input change, TV is turned off). + */ + declare export class VisibilityChangedEvent { + constructor(isVisible: boolean): VisibilityChangedEvent; + + /** + * Whether the Cast device is the active input or not. + */ + isVisible: boolean; + } + + /** + * Represents the system volume data. + */ + declare export class SystemVolumeData { + /** + * The level (from 0.0 to 1.0) of the system volume. + */ + level: number; + + /** + * Whether the system volume is muted or not. + */ + muted: boolean; + } + /** + * Event dispatched by @see{CastReceiverManager} when the system volume changes. + */ + declare export class SystemVolumeChangedEvent extends Event { + constructor(volume: SystemVolumeData): SystemVolumeChangedEvent; + + /** + * The system volume data + */ + data: SystemVolumeData; + } + /** + * Event dispatched by @see{@link CastReceiverManager} when the TV enters/leaves the standby state. + */ + declare export class StandbyChangedEvent { + constructor(isStandby: boolean): StandbyChangedEvent; + + /** + * + */ + isStandby: boolean; + } + /** + * Whether the TV is in standby or not. + */ + declare export class ShutdownEvent extends Event {} + + /** + * Event dispatched by @see{@link CastReceiverManager} when a sender is disconnected. + */ + declare export class SenderDisconnectedEvent extends Event { + constructor(senderId: string, userAgent: string): SenderDisconnectedEvent; + /** + * The ID of the sender connected. + */ + senderId: string; + + /** + * The user agent of the sender. + */ + userAgent: string; + + /** + * The reason the sender was disconnected. + */ + reason?: DisconnectReason; + } + + /** + * Event dispatched by @see{@link CastReceiverManager} when a sender is connected. + */ + declare export class SenderConnectedEvent extends Event { + constructor(senderId: string, userAgent: string): Event; + /** + * The ID of the sender connected. + */ + senderId: string; + + /** + * The user agent of the sender. + */ + userAgent: string; + } + + /** + * Represents the data of a connected sender device. + */ + declare export class Sender { + /** + * The sender Id. + */ + id: string; + + /** + * Indicate the sender supports large messages (>64KB). + */ + largeMessageSupported?: boolean; + + /** + * The userAgent of the sender. + */ + userAgent?: string; + } + + /** + * Event dispatched by CastReceiverManager when the system is ready. + */ + declare export class ReadyEvent { + constructor(applicationData: ApplicationData): ReadyEvent; + + /** + * The application data + */ + data: ApplicationData; + } + + /** + * Event dispatched by @see{@link CastReceiverManager} when the system needs to update the restriction on maximum video resolution. + */ + declare export class MaxVideoResolutionChangedEvent extends Event { + constructor(height: number): MaxVideoResolutionChangedEvent; + + /** + * Maximum video resolution requested by the system. The value of 0 means there is no restriction. + */ + height: number; + } + /** Event dispatched by @see{@link CastReceiverManager} when the systems starts to create feedback report. */ + declare export class FeedbackStartedEvent extends Event {} + /** Event dispatched by @see{@link CastReceiverContext} which contains system information. */ + declare export class Event { + constructor(type: EventType, data?: mixed): Event; + } + + /** Represents the data of the launched application. */ + declare export class ApplicationData { + id(): string; + launchingSenderId(): string; + name(): string; + namespaces(): Array; + sessionId(): number; + } +} +declare module 'cast.framework.ui' { + /** + * Player data changed event. Provides the changed field (type), and new value. + */ + declare export class PlayerDataChangedEvent { + constructor( + type: PlayerDataEventType, + field: string, + value: mixed, + ): PlayerDataChangedEvent; + + /** + * The field name that was changed. + */ + field: string; + + /** + * + */ + type: PlayerDataEventType; + + /** + * The new field value. + */ + value: mixed; + } + /** + * Player data binder. Bind a player data object to the player state. The player data will be updated to reflect correctly the current player state without firing any change event. + */ + declare export class PlayerDataBinder { + constructor(playerData: PlayerData | mixed): PlayerDataBinder; + + /** + * Add listener to player data changes. + */ + // addEventListener: (type: PlayerDataEventType, listener: PlayerDataChangedEventHandler); + + /** + * Remove listener to player data changes. + */ + // removeEventListener: (type: PlayerDataEventType, listener: PlayerDataChangedEventHandler); + } + /** + * Player data. Provide the player media and break state. + */ + declare export class PlayerData { + /** + * Array of breaks positions in percentage. + */ + breakPercentagePositions: Array; + + /** + * Content Type. + */ + contentType: ContentType; + + /** + * The number of the current playing break clip in the break. + */ + currentBreakClipNumber: number; + + /** + * Media current position in seconds, or break current position if playing break. + */ + currentTime: number; + + /** + * Whether the player metadata (ie: title, currentTime) should be displayed. This will be true if at least one field in the metadata should be displayed. In some cases, displayStatus will be true, but parts of the metadata should be hidden (ie: the media title while media is seeking). In these cases, additional css can be applied to hide those elements. For cases where the media is audio-only, this will almost always be true. In cases where the media is video, this will be true when: (1) the video is loading, buffering, or seeking (2) a play request was made in the last five seconds while media is already playing, (3) there is a request made to show the status in the last five seconds, or (4) the media was paused in the last five seconds. + */ + displayStatus: boolean; + + /** + * Media duration in seconds, Or break duration if playing break. + */ + duration: number; + + /** + * Indicate break clip can be skipped. + */ + isBreakSkippable: boolean; + + /** + * Indicate if the content is a live stream. + */ + isLive: boolean; + + /** + * Indicate that the receiver is playing a break. + */ + isPlayingBreak: boolean; + + /** + * Indicate the player is seeking (can be either during playing or pausing). + */ + isSeeking: boolean; + + /** + * Media metadata. + */ + metadata: MediaMetadata | mixed; + + /** + * Next Item subtitle. + */ + nextSubtitle: string; + + /** + * Next Item thumbnail url. + */ + nextThumbnailUrl: string; + + /** + * Next Item title. + */ + nextTitle: string; + + /** + * Number of break clips in current break. + */ + numberBreakClips: number; + + /** + * Flag to show/hide next item metadata. + */ + preloadingNext: boolean; + + /** + * Current player state. + */ + state: State; + + /** + * Content thumbnail url. + */ + thumbnailUrl: string; + + /** + * Content title. + */ + title: string; + + /** + * Provide the time a break is skipable - relative to current playback time. Undefined if not skippable. + */ + whenSkippable?: number; + } +} +declare module 'cast.framework.breaks' { + declare export class BreakSeekData { + constructor( + seekFrom: number, + seekTo: number, + breaks: Array, + ): BreakSeekData; + + /** + * List of breaks + */ + breaks: Array; + + /** + * Current playback time + */ + seekFrom: number; + + /** + * The time to seek to + */ + seekTo: number; + } + + /** Provide context information for break clip load interceptor. */ + declare export class BreakClipLoadInterceptorContext { + constructor(brk: Break): BreakClipLoadInterceptorContext; + + /** + * The container break for the break clip + */ + break: Break; + } + + /** Interface to manage breaks */ + declare export interface BreakManager { + /** + * Get current media break by id. + * @param {*} id + */ + getBreakById(id: string): Break | null; + + /** + * Get current media break clip by id + * @param {*} id + */ + getBreakClipById(id: string): BreakClip | null; + + /** Get current media break clips. */ + getBreakClips(): Array; + + /** Get current media breaks. */ + getBreaks(): Array; + + /** Returns true if watched breaks should be played. */ + getPlayWatchedBreak(): boolean; + + /** + * Provide an interceptor to allow developer to insert more break clips or modify current break clip before a break is started. + * If interceptor is null it will reset the interceptor to default one. + * By default VAST fetching and parsing logic in default interceptor. + * So if customized interceptor is set by developer, + * the VAST logic will be overridden and developers should implement their own VAST fetching and parsing logic in the provided interceptor. + * @param {*} interceptor + */ + setBreakClipLoadInterceptor( + interceptor: ( + breakClip: BreakClip, + breakClipLoaderContext?: BreakClipLoadInterceptorContext, + ) => void, + ): void; + + /** + * Provide an interceptor for developer to specify what breaks they want to play after seek. + * @param {*} seekInterceptor + */ + setBreakSeekInterceptor( + seekInterceptor: (breakSeekData: BreakSeekData) => void, + ): void; + + /** + * Set a flag to control if the watched client stitching break should be played. + * @param {*} playWatchedBreak + */ + setPlayWatchedBreak(playWatchedBreak: boolean): void; + + /** + * Provide an interceptor to modify VAST tracking URL before it is being sent to server. + * The input of the interceptor is a string of the tracking URL. + * The interceptor can either return a modified string of URL or a Promise of modified string of URL. + * The interceptor can also return null if you want to send the tracking URL by your own code instead of by CAF. + * @param {*} interceptor + */ + setVastTrackingInterceptor( + interceptor?: (trackingUrl: string) => void, + ): void; + } +} +declare module 'cast.framework.events' { + import type { EventType } from 'cast.framework.events'; + /** + * Event data for @see{@link EventType.SEGMENT_DOWNLOADED} event. + */ + declare export class SegmentDownloadedEvent { + constructor(downloadTime?: number, size?: number): SegmentDownloadedEvent; + + /** + * The time it took to download the segment, in milliseconds. + */ + downloadTime?: number; + + /** + * The number of bytes in the segment. + */ + size?: number; + } + + /** + * Event data for all events that represent requests made to the receiver. + */ + declare export class RequestEvent { + constructor( + type: EventType, + requestData?: RequestData, + senderId?: string, + ): RequestEvent; + + /** + * The data that was sent with the request. + */ + requestData?: RequestData; + + /** + * The sender id the request came from. + */ + senderId?: string; + } + + /** + * Event data for @see{@link EventType.MEDIA_STATUS} event. + */ + declare export class MediaStatusEvent { + constructor(mediaStatus?: MediaStatus): MediaStatusEvent; + + /** + * The media status that was sent. + */ + mediaStatus?: MediaStatus; + } + /** + * Event data for pause events forwarded from the MediaElement. + */ + declare export class MediaPauseEvent { + constructor(currentMediaTime?: number, ended?: boolean): MediaPauseEvent; + + /** + * Indicate if the media ended (indicates the pause was fired due to stream reached the end). + */ + ended?: boolean; + } + /** + * Event data for @see{@link EventType.MEDIA_FINISHED} event. + */ + declare export class MediaFinishedEvent { + constructor( + currentMediaTime?: number, + endedReason?: EndedReason, + ): MediaFinishedEvent; + + /** + * The time when the media finished (in seconds). For an item in a queue, this value represents the time in the currently playing queue item ( where 0 means the queue item has just started). + */ + currentTime?: number; + + /** + * The reason the media finished. + */ + endedReason?: EndedReason; + } + /** + * Event data for all events forwarded from the MediaElement. + */ + declare export class MediaElementEvent { + constructor(type: EventType, currentMediaTime?: number): MediaElementEvent; + + /** + * The time in the currently playing clip when the event was fired (in seconds). Undefined if playback has not started yet. + */ + currentMediaTime?: number; + } + /** + * Event data for all events pertaining to processing a load / preload request. made to the player. + */ + declare export class LoadEvent { + constructor(type: EventType, media?: MediaInformation): LoadEvent; + + /** + * Information about the media being loaded. + */ + media: MediaInformation; + } + /** + * Event data for @see{@link EventType.INBAND_TRACK_ADDED} event. + */ + declare export class InbandTrackAddedEvent { + constructor(track: Track): InbandTrackAddedEvent; + + /** + * Added track. + */ + track: Track; + } + + /** Event data for @see{@link EventType.ID3} event. */ + declare export class Id3Event { + constructor(segmentData: Uint8Array): Id3Event; + + /** + * The segment data. + */ + segmentData: Uint8Array; + } + /** + * Event data superclass for all events dispatched by @see{@link PlayerManager} + */ + declare export class Event { + constructor(type: EventType): Event; + + /** + * Type of the event. + */ + type: EventType; + } + /** + * Event data for @see{@link EventType.EMSG} event. + */ + declare export class EmsgEvent { + constructor(emsgData: mixed): EmsgEvent; + + /** + * The time that the event ends (in presentation time). Undefined if using legacy Dash support. + */ + endTime: mixed; + + /** + * The duration of the event (in units of timescale). Undefined if using legacy Dash support. + */ + eventDuration: mixed; + + /** + * A field identifying this instance of the message. Undefined if using legacy Dash support. + */ + id: mixed; + + /** + * Body of the message. Undefined if using legacy Dash support. + */ + messageData: mixed; + + /** + * The offset that the event starts, relative to the start of the segment this is contained in (in units of timescale). Undefined if using legacy Dash support. + */ + presentationTimeDelta: mixed; + + /** + * Identifies the message scheme. Undefined if using legacy Dash support. + */ + schemeIdUri: mixed; + + /** + * The segment data. This is only defined if using legacy Dash support. + */ + segmentData: mixed; + + /** + * The time that the event starts (in presentation time). Undefined if using legacy Dash support. + */ + startTime: mixed; + + /** + * Provides the timescale, in ticks per second. Undefined if using legacy Dash support. + */ + timescale: mixed; + + /** + * Specifies the value for the event. Undefined if using legacy Dash support. + */ + value: mixed; + } + /** + * Event data for @see{@link EventType.CLIP_ENDED} event. + */ + declare export class ClipEndedEvent { + constructor( + currentMediaTime: number, + endedReason?: EndedReason, + ): ClipEndedEvent; + + /** + * The time in media (in seconds) when clip ended. + */ + currentMediaTime: number; + + /** + * The reason the clip ended. + */ + endedReason?: EndedReason; + } + + /** + * Event data for @see{@link EventType.CACHE_LOADED} event. + */ + declare export class CacheLoadedEvent { + constructor(media?: MediaInformation): CacheLoadedEvent; + + /** + * Information about the media being cached. + */ + media: MediaInformation; + } + + declare export class CacheItemEvent { + constructor(type: EventType, url: string): CacheItemEvent; + + /** + * The URL of data fetched from cache + */ + url: string; + } + declare export class BufferingEvent { + constructor(isBuffering: boolean): BufferingEvent; + + /** + * True if the player is entering a buffering state. + */ + isBuffering: boolean; + } + + declare export class BreaksEvent { + constructor( + type: EventType, + currentMediaTime?: number, + index?: number, + total?: number, + whenSkippable?: number, + endedReason?: EndedReason, + breakClipId?: string, + ): BreaksEvent; + + /** + * The break clip's id. Refer to BreakClip.id + */ + breakClipId: string; + + /** + * The time in the currently playing media when the break event occurred. + */ + currentMediaTime: string; + + /** + * The reason the break clip ended. + */ + endedReason: EndedReason; + + /** + * Index of break clip, which starts from 1. + */ + index: number; + + /** + * Total number of break clips. + */ + total: number; + + /** + * When to skip current break clip in sec, after break clip begins to play. + */ + whenSkippable: number; + } + + /** + * Event data for @see {@link EventType.BITRATE_CHANGED} event. + */ + declare export class BitrateChangedEvent { + constructor(totalBitrate?: number): BitrateChangedEvent; + + /** The bitrate of the media (audio and video) in bits per second. */ + totalBitrate: number; + } +} + +declare module 'cast.framework.events.category' { + declare export type EventType = { + REQUEST_SEEK: 'REQUEST_SEEK', + REQUEST_LOAD: 'REQUEST_LOAD', + REQUEST_STOP: 'REQUEST_STOP', + REQUEST_PAUSE: 'REQUEST_PAUSE', + REQUEST_PLAY: 'REQUEST_PLAY', + REQUEST_PLAY_AGAIN: 'REQUEST_PLAY_AGAIN', + REQUEST_PLAYBACK_RATE_CHANGE: 'REQUEST_PLAYBACK_RATE_CHANGE', + REQUEST_SKIP_AD: 'REQUEST_SKIP_AD', + REQUEST_VOLUME_CHANGE: 'REQUEST_VOLUME_CHANGE', + REQUEST_EDIT_TRACKS_INFO: 'REQUEST_EDIT_TRACKS_INFO', + REQUEST_EDIT_AUDIO_TRACKS: 'REQUEST_EDIT_AUDIO_TRACKS', + REQUEST_SET_CREDENTIALS: 'REQUEST_SET_CREDENTIALS', + REQUEST_LOAD_BY_ENTITY: 'REQUEST_LOAD_BY_ENTITY', + REQUEST_USER_ACTION: 'REQUEST_USER_ACTION', + REQUEST_DISPLAY_STATUS: 'REQUEST_DISPLAY_STATUS', + REQUEST_CUSTOM_COMMAND: 'REQUEST_CUSTOM_COMMAND', + REQUEST_FOCUS_STATE: 'REQUEST_FOCUS_STATE', + REQUEST_QUEUE_LOAD: 'REQUEST_QUEUE_LOAD', + REQUEST_QUEUE_INSERT: 'REQUEST_QUEUE_INSERT', + REQUEST_QUEUE_UPDATE: 'REQUEST_QUEUE_UPDATE', + REQUEST_QUEUE_REMOVE: 'REQUEST_QUEUE_REMOVE', + REQUEST_QUEUE_REORDER: 'REQUEST_QUEUE_REORDER', + REQUEST_QUEUE_GET_ITEM_RANGE: 'REQUEST_QUEUE_GET_ITEM_RANGE', + REQUEST_QUEUE_GET_ITEMS: 'REQUEST_QUEUE_GET_ITEMS', + REQUEST_QUEUE_GET_ITEM_IDS: 'REQUEST_QUEUE_GET_ITEM_IDS', + BREAK_CLIP_ENDED: 'BREAK_CLIP_ENDED', + BREAK_CLIP_STARTED: 'BREAK_CLIP_STARTED', + BUFFERING: 'BUFFERING', + ERROR: 'ERROR', + MEDIA_FINISHED: 'MEDIA_FINISHED', + MEDIA_STATUS: 'MEDIA_STATUS', + PAUSE: 'PAUSE', + PLAYER_LOADING: 'PLAYER_LOADING', + PLAYER_LOAD_COMPLETE: 'PLAYER_LOAD_COMPLETE', + PLAYER_PRELOADING: 'PLAYER_PRELOADING', + PLAYER_PRELOADING_CANCELLED: 'PLAYER_PRELOADING_CANCELLED', + PLAYING: 'PLAYING', + REQUEST_PRECACHE: 'REQUEST_PRECACHE', + RATE_CHANGE: 'RATE_CHANGE', + SEEKED: 'SEEKED', + SEEKING: 'SEEKING', + }; +} + +declare module 'cast.framework.messages' { + declare export type RepeatMode = { + REPEAT_OFF: 'REPEAT_OFF', + REPEAT_ALL: 'REPEAT_ALL', + REPEAT_SINGLE: 'REPEAT_SINGLE', + REPEAT_ALL_AND_SHUFFLE: 'REPEAT_ALL_AND_SHUFFLE', + }; + + declare export type QueueType = { + ALBUM: 'ALBUM', + PLAYLIST: 'PLAYLIST', + AUDIOBOOK: 'AUDIOBOOK', + RADIO_STATION: 'RADIO_STATION', + PODCAST_SERIES: 'PODCAST_SERIES', + TV_SERIES: 'TV_SERIES', + VIDEO_PLAYLIST: 'VIDEO_PLAYLIST', + LIVE_TV: 'LIVE_TV', + MOVIE: 'MOVIE', + }; + declare export type QueueChangeType = { + INSERT: 'INSERT', + REMOVE: 'REMOVE', + ITEMS_CHANGE: 'ITEMS_CHANGE', + UPDATE: 'UPDATE', + NO_CHANGE: 'NO_CHANGE', + }; + + declare export type PlayerState = { + IDLE: 'IDLE', + PLAYING: 'PLAYING', + PAUSED: 'PAUSED', + BUFFERING: 'BUFFERING', + }; + + declare export type PlayerStringId = { + FREE_TRIAL_ABOUT_TO_EXPIRE: '', + SUBSCRIPTION_ABOUT_TO_EXPIRE: '', + STREAM_HIJACKED: '', + }; + /** + * RefreshCredentials request data. + */ + declare export class RefreshCredentialsRequestData {} + + /** + * Media event SET_VOLUME request data. + */ + declare export class VolumeRequestData extends RequestData { + /** + * The media stream volume + */ + volume?: Volume; + } + + /** + * Represents the volume of a media session stream. + */ + declare export class Volume { + /** + * Value from 0 to 1 that represents the current stream volume level. + */ + level?: number; + + /** + * Whether the stream is muted. + */ + muted?: boolean; + } + + /** + * Video information such as video resolution and High Dynamic Range (HDR). + */ + declare export class VideoInformation { + constructor( + width: number, + height: number, + hdrType: HdrType, + ): VideoInformation; + + /** + * + */ + width: number; + + /** + * + */ + height: number; + + /** + * + */ + hdrType: HdrType; + } + + /** + * VAST ad request configuration. + */ + declare export class VastAdsRequest { + /** + * Specifies a VAST document to be used as the ads response instead of making a request via an ad tag url. This can be useful for debugging and other situations where a VAST response is already available. + */ + adsResponse?: string; + + /** + * URL for VAST file. + */ + adTagUrl?: string; + } + + /** + * UserAction request data. + */ + declare export class UserActionRequestData { + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source?: string; + + /** + * User action to be handled by the application. + */ + userAction?: UserAction; + + /** + * Optional context information for the user action. + */ + userActionContext?: UserActionContext; + } + + /** + * A TV episode media description. + */ + declare export class TvShowMediaMetadata { + /** + * TV episode number. A positive integer. + */ + episode?: number; + + /** + * @deprecated use episode instead + */ + episodeNumber?: number; + + /** + * @deprecated use episode instead + */ + episodeTitle?: string; + + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images?: Array; + + /** + * ISO 8601 date when the episode originally aired, e.g. 2014-02-10. + */ + originalAirdate?: string; + + /** + * @deprecated use originalAirdate instead. + */ + releaseYear?: number; + + /** + * TV episode season. A positive integer. + */ + season?: number; + + /** + * @deprecated use season instead. + */ + seasonNumber?: number; + + /** + * TV series title. + */ + seriesTitle?: string; + + /** + * TV episode title. + */ + title?: string; + } + /** + * Describes track metadata information. + */ + declare export class Track { + constructor(trackId: number, trackType: TrackType): Track; + + /** + * Custom data set by the receiver application. + */ + customData?: string; + + /** + * Language tag as per RFC 5646 (If subtype is “SUBTITLES” it is mandatory). + */ + language?: string; + + /** + * A descriptive, human readable name for the track. For example "Spanish". + */ + name?: string; + + /** + * For text tracks, the type of text track. + */ + subtype?: string; + + /** + * It can be the url of the track or any other identifier that allows the receiver to find the content (when the track is not inband or included in the manifest). For example it can be the url of a vtt file. + */ + trackContentId?: string; + + /** + * It represents the MIME type of the track content. For example if the track is a vtt file it will be ‘text/vtt’. This field is needed for out of band tracks, so it is usually provided if a trackContentId has also been provided. It is not mandatory if the receiver has a way to identify the content from the trackContentId, but recommended. The track content type, if provided, must be consistent with the track type. + */ + trackContentType?: string; + + /** + * Unique identifier of the track within the context of a MediaInformation object. + */ + trackId?: number; + + /** + * The type of track. + */ + type: TrackType; + } + /** + * Describes style information for a text track. + */ + declare export class TextTrackStyle { + /** + * The background 32 bit RGBA color. The alpha channel should be used for transparent backgrounds. + */ + backgroundColor?: string; + + /** + * Custom data set by the receiver application. + */ + customData?: mixed; + + /** + * RGBA color for the edge, this value will be ignored if edgeType is NONE. + */ + edgeColor?: string; + + /** + * + */ + edgeType?: TextTrackEdgeType; + + /** + * If the font is not available in the receiver the fontGenericFamily will be used. + */ + fontFamily?: string; + + /** + * The text track generic family. + */ + fontGenericFamily?: TextTrackFontGenericFamily; + + /** + * The font scaling factor for the text track (the default is 1). + */ + fontScale?: number; + + /** + * The text track font style. + */ + fontStyle?: TextTrackFontStyle; + + /** + * The foreground 32 bit RGBA color. + */ + foregroundColor?: string; + + /** + * 32 bit RGBA color for the window. This value will be ignored if windowType is NONE. + */ + windowColor?: string; + + /** + * Rounded corner radius absolute value in pixels (px). This value will be ignored if windowType is not ROUNDED_CORNERS. + */ + windowRoundedCornerRadius?: number; + + /** + * The window concept is defined in CEA-608 and CEA-708. In WebVTT is called a region. + */ + windowType?: TextTrackWindowType; + } + declare export class Track {} + + /** + * Media event playback rate request data. + */ + declare export class SetPlaybackRateRequestData extends RequestData { + /** + * New playback rate (>0). + */ + playbackRate?: number; + + /** + * New playback rate relative to current playback rate. New rate will be the result of multiplying the current rate with the value. For example a value of 1.1 will increase rate by 10%. (Only used if the playbackRate value is not provided). + */ + relativePlaybackRate?: number; + } + + /** + * SetCredentials request data. + */ + declare export class SetCredentialsRequestData { + /** + * Credentials to use by receiver. + */ + credentials?: string; + + /** + * If it is a response for refresh credentials, it will indicate the request id of the refresh credentials request. + */ + forRequestId?: number; + + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source?: string | null; + } + + /** + * Media event SEEK request data. + */ + declare export class SeekRequestData extends RequestData { + /** + * Seconds since beginning of content. + */ + currentTime?: number; + + /** + * Seconds relative to the current playback position. If this field is defined, the currentTime field will be ignored. + */ + relativeTime?: number; + + /** + * The playback state after a SEEK request. + */ + resumeState?: SeekResumeState; + } + + /** + * Provides seekable range in seconds. + */ + declare export class SeekableRange { + constructor(start?: number, end?: number): SeekableRange; + + /** + * End of the seekable range in seconds. + */ + end?: number; + + /** + * Start of the seekable range in seconds. + */ + start?: number; + } + + /** + * Media event request data. + */ + declare export class RequestData { + constructor(type: MessageType): RequestData; + + /** + * Application-specific data for this request. It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + */ + customData?: mixed; + + /** + * Id of the media session that the request applies to. + */ + mediaSessionId?: number; + + /** + * Id of the request, used to correlate request/response. + */ + requestId: number; + } + + /** + * Media event UPDATE queue request data. + */ + declare export class QueueUpdateRequestData { + /** + * ID of the current media Item after the deletion (if not provided, the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted, the currentItem will point to the next logical item in the list). + */ + currentItemId?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided, this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * List of queue items to be updated. No reordering will happen, the items will retain the existing order. + */ + items?: Array; + + /** + * Skip/Go back number of items with respect to the position of currentItem (it can be negative). If it is out of boundaries, the currentItem will be the next logical item in the queue wrapping around the boundaries. The new currentItem position will follow the rules of the queue repeat behavior. + */ + jump?: number; + + /** + * Behavior of the queue when all items have been played. + */ + repeatMode?: RepeatMode; + + /** + * Shuffle the queue items when the update is processed. After the queue items are shuffled, the item at the currentItem position will be loaded. + */ + shuffle?: boolean; + } + + /** + * Media event queue REORDER request data. + */ + declare export class QueueReorderRequestData extends RequestData { + constructor(itemIds: Array): QueueReorderRequestData; + + /** + * ID of the current media Item after the deletion (if not provided, the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted, the currentItem will point to the next logical item in the list). + */ + currentItemId?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided, this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * ID of the item that will be located immediately after the reordered list. If the ID is not found or it is not provided, the reordered list will be appended at the end of the existing list. + */ + insertBefore?: number; + + /** + * IDs of the items to be reordered, in the new order. Items not provided will keep their existing order. The provided list will be inserted at the position determined by insertBefore. For example: + + If insertBefore is not specified Existing queue: “A”,”D”,”G”,”H”,”B”,”E” itemIds: “D”,”H”,”B” New Order: “A”,”G”,”E”,“D”,”H”,”B” + + If insertBefore is “A” Existing queue: “A”,”D”,”G”,”H”,”B” itemIds: “D”,”H”,”B” New Order: “D”,”H”,”B”,“A”,”G”,”E” + + If insertBefore is “G” Existing queue: “A”,”D”,”G”,”H”,”B” itemIds: “D”,”H”,”B” New Order: “A”,“D”,”H”,”B”,”G”,”E” + */ + itemIds: Array; + } + + /** + * Media event queue REMOVE request data. + */ + declare export class QueueRemoveRequestData extends RequestData { + constructor(itemIds: Array): QueueRemoveRequestData; + + /** + * ID of the current media Item after the deletion (if not provided, the currentItem value will be the same as before the deletion; if it does not exist because it has been deleted, the currentItem will point to the next logical item in the list). + */ + currentItemId?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided, this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * IDs of queue items to be deleted. + */ + itemIds?: Array; + } + /** + * Media event queue LOAD request data. + */ + declare export class QueueLoadRequestData extends RequestData { + constructor(items: Array): QueueLoadRequestData; + + /** + * Seconds (since the beginning of content) to start playback of the first item to be played. If provided, this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user casts the item that was playing locally so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * Behavior of the queue when all items have been played. + */ + items: Array; + + /** + * Id of the request, used to correlate request/response. + */ + repeatMode?: RepeatMode; + + /** + * The index of the item in the items array that must be the first currentItem (the item that will be played first). Note this is the index of the array (starts at 0) and not the itemId (as it is not known until the queue is created). If repeatMode is REPEAT_OFF playback will end when the last item in the array is played (elements before the startIndex will not be played). This may be useful for continuation scenarios where the user was already using the sender app and in the middle decides to cast. In this way the sender app does not need to map between the local and remote queue positions or saves one extra QUEUE_UPDATE request. + */ + startIndex?: number; + } + + /** + * Queue item information. Application developers may need to create a QueueItem to insert a queue element using InsertQueueItems. In this case they should not provide an itemId (as the actual itemId will be assigned when the item is inserted in the queue). This prevents ID collisions with items added from a sender app. + */ + declare export class QueueItem { + constructor(opt_itemId?: number): QueueItem; + + /** + * Array of Track trackIds that are active. If the array is not provided, the default tracks will be active. + */ + activeTrackIds?: Array; + + /** + * If the autoplay parameter is not specified or is true, the media player will begin playing the element in the queue when the item becomes the currentItem. + */ + autoplay?: boolean; + + /** + * The application can define any extra queue item information needed. + */ + customData?: mixed; + + /** + * Unique identifier of the item in the queue. The attribute is optional because for LOAD or INSERT should not be provided (as it will be assigned by the receiver when an item is first created/inserted). + */ + itemId?: number; + + /** + * Metadata (including contentId) of the playlist element. + */ + media?: MediaInformation; + + /** + * Playback duration of the item, if it is larger than the actual duration - startTime it will be ignored (default behavior). It can be negative, in such case the duration will be the actual asset duration minus the duration provided. It can be used for photo slideshows to control the duration the item should be presented or for live events to control the duration that the program should be played. It may be useful for autoplay scenarios to avoid displaying all the credits after an episode has ended. + */ + playbackDuration?: number; + + /** + * This parameter is a hint for the receiver to preload this media item before it is played. It allows for a smooth transition between items played from the queue. The time is expressed in seconds, relative to the beginning of this item playback (usually the end of the previous item playback). Only positive values are valid. For example, if the value is 10 seconds, this item will be preloaded 10 seconds before the previous item has finished. The receiver will try to honor this value but will not guarantee it, for example if the value is larger than the previous item duration the receiver may just preload this item shortly after the previous item has started playing (there will never be two items being preloaded in parallel). Also, if an item is inserted in the queue just after the currentItem and the time to preload is higher than the time left on the currentItem, the preload will just happen as soon as possible. + */ + preloadTime?: number; + + /** + * Seconds since beginning of content. If the content is live content, and startTime is not specified, the stream will start at the live position. + */ + startTime?: number; + } + + /** + * Media event queue INSERT request data. + */ + declare export class QueueInsertRequestData extends RequestData { + constructor(items: Array): QueueInsertRequestData; + + /** + * ID of the current media Item after the insertion (if not provided, the currentItem value will be the same as before the insertion). + */ + currentItemId?: number; + + /** + * Index (relative to the items array, starting with 0) of the new current media Item. For inserted items we use the index (similar to startIndex in QUEUE_LOAD) and not currentItemId, because the itemId is unknown until the items are inserted. If not provided, the currentItem value will be the same as before the insertion (unless currentItemId is provided). This param allows to make atomic the common use case of insert and play an item. + */ + currentItemIndex?: number; + + /** + * Seconds since the beginning of content to start playback of the current item. If provided, this value will take precedence over the startTime value provided at the QueueItem level but only the first time the item is played. This is to cover the common case where the user jumps to the middle of an item so the currentTime does not apply to the item permanently like the QueueItem startTime does. It avoids having to reset the startTime dynamically (that may not be possible if the phone has gone to sleep). + */ + currentTime?: number; + + /** + * ID of the item that will be located immediately after the inserted list. If the ID is not found or it is not provided, the list will be appended at the end of the existing list. + */ + insertBefore?: number; + + /** + * List of queue items. The itemId field of the items should be empty. It is sorted (first element will be played first). + */ + items: Array; + } + + /** + * Represents a data message containing the full list of queue ids. + */ + declare export class QueueIds { + /** + * List of queue item ids. + */ + itemIds?: Array; + + /** + * The corresponding request id. + */ + requestId?: number; + + /** + * + */ + type: MessageType; + } + + /** + * Queue data as part of the LOAD request. + */ + declare export class QueueData { + constructor( + id?: string, + name?: string, + description?: string, + repeatMode?: RepeatMode, + items?: Array, + startIndex?: number, + startTime?: number, + ): QueueData; + + /** + * Description of the queue. + */ + description?: string; + + /** + * Optional Queue entity id, provide Google Assistant deep link. + */ + entity?: string; + + /** + * Id of the queue. + */ + id?: string; + + /** + * Array of queue items. It is sorted (first element will be played first). + */ + items?: Array; + + /** + * Name of the queue. + */ + name?: string; + + /** + * Queue type, e.g. album, playlist, radio station, tv series, etc. + */ + queueType?: QueueType; + + /** + * Continuous playback behavior of the queue. + */ + repeatMode?: RepeatMode; + + /** + * The index of the item in the queue that should be used to start playback first. + */ + startIndex?: number; + + /** + * Seconds (since the beginning of content) to start playback of the first item. + */ + startTime?: number; + } + + /** + * Represents a queue change message, such as insert, remove, and update. + */ + declare export class QueueChange { + /** + * The actual queue change type. + */ + changeType?: QueueChangeType; + + /** + * The id to insert the list of itemIds before. + */ + insertBefore?: number; + + /** + * List of changed itemIds. + */ + itemIds?: Array; + + /** + * The corresponding request id. + */ + requestId?: number; + + /** + * The queue change sequence ID. Used to coordinate state sync between various senders and the receiver. + */ + sequenceNumber?: number; + + /** + * + */ + type: MessageType; + } + + /** + * Media event PRELOAD request data. + */ + declare export class PreloadRequestData extends LoadRequestData { + constructor(itemId: number): PreloadRequestData; + + /** + * The ID of the queue item. + */ + itemId: number; + } + + /** + * Media event PRECACHE request data. (Some fields of the load request, like autoplay and queueData, are ignored). + */ + declare export class PrecacheRequestData extends LoadRequestData { + constructor(data?: string): PrecacheRequestData; + + /** + * Application precache data. + */ + precacheData?: string; + } + + /** + * PlayString request data. + */ + declare export class PlayStringRequestData { + constructor( + stringId: PlayStringId, + opt_arguments?: Array, + ): PlayStringRequestData; + + /** + * An optional array of string values to be filled into the text. + */ + arguments?: Array; + + /** + * An identifier for the text to be played back. + */ + stringId: PlayStringId; + } + + /** + * A photo media description. + */ + declare export class PhotoMediaMetadata { + /** + * Name of the photographer. + */ + artist?: string; + + /** + * ISO 8601 date and time the photo was taken, e.g. 2014-02-10T15:47:00Z. + */ + creationDateTime?: string; + + /** + * Photo height, in pixels. + */ + height?: number; + + /** + * Images associated with the content. Examples would include a photo thumbnail. + */ + images: Array; + + /** + * Latitude. + */ + latitude?: number; + + /** + * Location where the photo was taken. For example, "Seattle, Washington, USA". + */ + location?: string; + + /** + * Longitude. + */ + longitude?: number; + + /** + * Photo title. + */ + title?: string; + + /** + * Photo width, in pixels. + */ + width?: number; + } + + /** + * A music track media description. + */ + declare export class MusicTrackMediaMetadata { + /** + * Album artist name. + */ + albumArtist?: string; + + /** + * Album name. + */ + albumName?: string; + + /** + * Track artist name. + */ + artist?: string; + + /** + * @deprecated: use @see{@link artist} instead + */ + artistName: string; + + /** + * Track composer name. + */ + composer?: string; + + /** + * Disc number. A positive integer. + */ + discNumber?: number; + + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images: Array; + + /** + * ISO 8601 date when the track was released, e.g. 2014-02-10. + */ + releaseDate?: string; + + /** + * @deprecated: Use @see{@link releaseDate} instead + */ + releaseYear?: string; + + /** + * Track name. + */ + songName?: string; + + /** + * Track title. + */ + title?: string; + + /** + * Track number in album. A positive integer. + */ + trackNumber?: number; + } + + /** + * A movie media description. + */ + declare export class MovieMediaMetadata { + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images: Array; + + /** + * ISO 8601 date when the movie was released, e.g. 2014-02-10. + */ + releaseDate?: string; + + /** + * @deprecated: use @see{@link releaseDate} instead + */ + releaseYear?: number; + + /** + * Movie studio. + */ + studio?: string; + + /** + * Movie subtitle. + */ + subtitle?: string; + + /** + * Movie title. + */ + title?: string; + } + /** + * Represents the status of a media session. + */ + declare export class MediaStatus { + /** + * List of IDs corresponding to the active tracks. + */ + activeTrackIds: Array; + + /** + * Status of break, if receiver is playing break. This field will be defined only when receiver is playing break. + */ + breakStatus: BreakStatus; + + /** + * ID of this media item (the item that originated the status change). + */ + currentItemId?: number; + + /** + * The current playback position. + */ + currentTime: number; + + /** + * Application-specific media status. + */ + customData?: mixed; + + /** + * Extended media status information. + */ + extendedStatus: ExtendedMediaStatus; + + /** + * If the state is IDLE, the reason the player went to IDLE state. + */ + idleReason: IdleReason; + + /** + * List of media queue items. + */ + items: Array; + + /** + * Seekable range of a live or event stream. It uses relative media time in seconds. It will be undefined for VOD streams. + */ + liveSeekableRange: LiveSeekableRange; + + /** + * ID of the media Item currently loading. If there is no item being loaded, it will be undefined. + */ + loadingItemId?: number; + + /** + * The media information. + */ + media: MediaInformation; + + /** + * Unique id for the session. + */ + mediaSessionId: number; + + /** + * The playback rate. + */ + playbackRate: number; + + /** + * The playback state. + */ + playerState: PlayerState; + + /** + * ID of the next Item, only available if it has been preloaded. Media items can be preloaded and cached temporarily in memory, so when they are loaded later on, the process is faster (as the media does not have to be fetched from the network). + */ + preloadedItemId?: number; + + /** + * Queue data. + */ + queueData: QueueData; + + /** + * The behavior of the queue when all items have been played. + */ + repeatMode: RepeatMode; + + /** + * The commands supported by this player. + */ + supportedMediaCommands: number; + + /** + * + */ + type: MessageType; + + /** + * The video information. + */ + videoInfo: VideoInformation; + + /** + * The current stream volume. + */ + volume: Volume; + } + /** + * Common media metadata used as part of MediaInformation + */ + declare export class MediaMetadata { + constructor(type: MetadataType): MediaMetadata; + + /** + * The type of metadata + */ + metadataType: MetadataType; + } + + /** + * Represents the media information. + */ + declare export class MediaInformation { + /** + * Partial list of break clips that includes current break clip that receiver is playing or ones that receiver will play shortly after, instead of sending whole list of clips. This is to avoid overflow of MediaStatus message. + */ + breakClips: Array; + + /** + * List of breaks. + */ + breaks: Array; + + /** + * Typically the url of the media. + */ + contentId: string; + + /** + * The content MIME type. + */ + contentType: string; + + /** + * Optional media url, to allow using contentId for real id. If contentUrl is provided, it will be used as media url, otherwise the contentId will be used as the media url. + */ + contentUrl?: string; + + /** + * Application-specific media information. + */ + customData?: mixed; + + /** + * The media duration. + */ + duration?: number; + + /** + * Optional Media entity, provide Google Assistant deep link. + */ + entity?: string; + + /** + * The format of the HLS media segment. + */ + hlsSegmentFormat: HlsSegmentFormat; + + /** + * The media metadata. + */ + metadata: MediaMetadata; + + /** + * The stream type. + */ + streamType: StreamType; + + /** + * The style of text track. + */ + textTrackStyle: TextTrackStyle; + + /** + * The media tracks. + */ + tracks: Array; + } + + /** + * Media event LOAD request data. + */ + declare export class LoadRequestData extends RequestData { + /** + * Array of trackIds that are active. If the array is not provided, the default tracks will be active. + */ + activeTrackIds: Array; + + /** + * If the autoplay parameter is specified, the media player will begin playing the content when it is loaded. Even if autoplay is not specified,the media player implementation may choose to begin playback immediately. + */ + autoplay?: boolean; + + /** + * Optional user credentials. + */ + credentials?: string; + + /** + * Optional credentials type. The type 'cloud' is a reserved type used by load requests that were originated by voice assistant commands. + */ + credentialsType?: string; + + /** + * Seconds since beginning of content. If the content is live content, and currentTime is not specified, the stream will start at the live position. + */ + currentTime?: number; + + /** + * If the autoplay parameter is specified, the media player will begin playing the content when it is loaded. Even if autoplay is not specified, the media player implementation may choose to begin playback immediately. + */ + media: MediaInformation; + + /** + * The media playback rate. + */ + playbackRate?: number; + + /** + * Queue data. + */ + queueData: QueueData; + } + + /** + * LoadByEntity request data. + */ + declare export class LoadByEntityRequestData { + /** + * Content entity information, typically represented by a stringified JSON object + */ + entity: string; + + /** + * Shuffle the items to play. + */ + shuffle?: boolean; + + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source?: string | null; + } + + /** + * Provides live seekable range with start and end time in seconds and two more attributes. + */ + declare export class LiveSeekableRange { + constructor( + start?: number, + end?: number, + isMovingWindow?: boolean, + isLiveDone?: boolean, + ): LiveSeekableRange; + + /** + * A boolean value indicates whether a live stream is ended. If it is done, the end of live seekable range should stop updating. + */ + isLiveDone?: boolean; + + /** + * A boolean value indicates whether the live seekable range is a moving window. If false, it will be either a expanding range or a fixed range meaning live has ended. + */ + isMovingWindow?: boolean; + } + + /** + * Represents a data message containing item information for each requested ids. + */ + declare export class ItemsInfo { + /** + * List of changed itemIds. + */ + items: Array; + + /** + * The corresponding request id. + */ + requestId?: number; + + /** + * + */ + type: MessageType; + } + + /** + * An image that describes a receiver application or media item. + * This could be an application icon, cover art, or a thumbnail. + */ + declare export class Image { + constructor(url: string): Image; + + /** + * The height of the image. + */ + height?: number; + + /** + * the URL to the image + */ + url: string; + + /** + * The width of the image + */ + width?: number; + } + /** Media event GET_STATUS request data. */ + declare export class GetStatusRequestData extends RequestData { + /** + * The options of a GET_STATUS request. + */ + options: GetStatusOptions; + } + + /** + * Get items info request data. + */ + declare export class GetItemsInfoRequestData extends RequestData { + constructor(itemIds: Array): GetItemsInfoRequestData; + + /** + * List of item ids to be requested. + */ + itemIds: Array; + } + /** + * A generic media description. + */ + declare export class GenericMediaMetadata { + /** + * Content images. Examples would include cover art or a thumbnail of the currently playing media. + */ + images: Array; + + /** + * ISO 8601 date and/or time when the content was released, e.g. 2014-02-10. + */ + releaseDate?: string; + + /** + *@deprecated - use @see{@link releaseDate} instead + */ + releaseYear?: number; + + /** + * Content subtitle. + */ + subtitle?: string; + + /** + * Content title. + */ + title?: string; + } + + /** + * Focus state change message. + */ + declare export class FocusStateRequestData { + /** + * The focus state of the app. + */ + state: FocusState; + } + + /** Fetch items request data. */ + declare export class FetchItemsRequestData extends RequestData { + constructor( + itemId: number, + nextCount: number, + prevCount: number, + ): FetchItemsRequestData; + + /** + * ID of the reference media item for fetching more items. + */ + itemId: number; + + /** + * Number of items after the reference item to be fetched. + */ + nextCount: number; + + /** + * Number of items before the reference item to be fetched. + */ + prevCount: number; + } + + /** + * Extended media status information + */ + declare export class ExtendedMediaStatus { + constructor( + playerState: MediaInformation, + opt_media?: MediaInformation, + ): ExtendedMediaStatus; + + /** + * + */ + media: MediaInformation; + + /** + * + */ + playerState: ExtendedPlayerState; + } + + /** Event data for @see{@link EventType.ERROR} event. */ + declare export class ErrorEvent { + constructor( + detailedErrorCode?: DetailedErrorCode, + error?: mixed, + ): ErrorEvent; + /** + * An error code representing the cause of the error. + */ + detailedErrorCode?: DetailedErrorCode; + + /** + * The error object. + * This could be an Error object (e.g., if an Error was thrown in an event handler) + * or an object with error information (e.g., if the receiver received an invalid command). + */ + error?: mixed; + } + + declare export class ErrorData { + constructor(type: ErrorType): ErrorData; + + /** + * Application-specific data for this request. + * It enables the sender and receiver to easily extend the media protocol without having to use a new namespace with custom messages. + */ + customData?: mixed; + + /** + Id of the request, used to correlate request/response. + */ + requestId?: number; + } + + /** Media event EDIT_TRACKS_INFO request data. */ + declare export class EditTracksInfoRequestData extends RequestData { + /** + * Array of the Track trackIds that should be active. + * If it is not provided, the active tracks will not change. + * If the array is empty, no track will be active. + */ + activeTrackIds?: Array; + + /** + * Flag to enable or disable text tracks. + * If false it will disable all text tracks, + * if true it will enable the first text track, or the previous active text tracks. + * This flag is ignored if activeTrackIds or language is provided. + */ + enableTextTracks?: boolean; + + /** + * Indicates that the provided language was not explicit user request, but rather inferred from used language in voice query. + * It allows receiver apps to use user saved preference instead of spoken language. + */ + isSuggestedLanguage?: boolean; + + /** + * Language for the tracks that should be active. The language field will take precedence over activeTrackIds if both are specified. + */ + language?: string; + + /** + * + */ + textTrackStyle?: TextTrackStyle; + } + + /** + * Media event EDIT_AUDIO_TRACKS request data. If language is not provided, the default audio track for the media will be enabled. + */ + declare export class EditAudioTracksRequestData extends RequestData { + /** + * Indicates that the provided language was not explicit user request, but rather inferred from used language in voice query. + * It allows receiver apps to use user saved preference instead of spoken language. + */ + isSuggestedLanguage?: boolean; + + /** + * + */ + language?: string; + } + + /** DisplayStatus request data. */ + declare export class DisplayStatusRequestData { + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source: string; + } + + /** CustomCommand request data. */ + declare export class CustomCommandRequestData { + /** + * Custom Data, typically represented by a stringified JSON object. + */ + data: string; + + /** + * Optional request source. It contain the assistent query that initiate the request. + */ + source: string; + } + /** Cloud media status. Media status that is only sent to the cloud sender. */ + declare export class CloudMediaStatus { + constructor(): CloudMediaStatus; + } + + declare export class BreakStatus { + constructor( + currentBreakTime: number, + currentBreakClipTime: number, + ): BreakStatus; + + /** + * Id of current break clip. + */ + breakClipId: string; + + /** + * Id of current break. + */ + breakId: string; + + /** + * Time in sec elapsed after current break clip starts. + */ + currentBreakClipTime: number; + + /** + * Time in sec elapsed after current break starts. + */ + currentBreakTime: number; + + /** + * The time in sec when this break clip becomes skippable. + * 5 means that end user can skip this break clip after 5 seconds. + * If this field is not defined, it means that current break clip is not skippable. + */ + whenSkippable: number; + } + + /** + * Represents break clip (e.g. a clip of ad during ad break) + */ + declare export class BreakClip { + constructor(id: string): BreakClip; + + /** + * Url of page that sender will display, when end user clicks link on sender UI, while receiver is playing this clip. + */ + clickThroughUrl?: string; + /** + * Typically the url of the break media (playing on the receiver). + */ + contentId?: string; + /** + * The content MIME type. + */ + contentType?: string; + /** + * Optional break media url, to allow using contentId for real id. + * If contentUrl is provided, it will be used as media url, otherwise the contentId will be used as the media url. + */ + contentUrl?: string; + /** + * Application-specific break clip data. + */ + customData?: mixed; + /** + * Duration of break clip in sec. + */ + duration?: number; + /** + * The format of the HLS media segment. + */ + hlsSegmentFormat: HlsSegmentFormat; + /** + * Unique id of break clip. + */ + id: string; + /** + * Url of content that sender will display while receiver is playing this clip. + */ + posterUrl?: string; + /** + * Title of break clip. Sender might display this on its screen, if provided. + */ + title?: string; + /** + * VAST ad request configuration. Used if contentId or contentUrl is not provided. + */ + vastAdsRequest: VastAdsRequest; + /** + * The time in sec when this break clip becomes skippable. + * 5 means that end user can skip this break clip after 5 seconds. + * If this field is not defined, it means that current break clip is not skippable. + */ + whenSkippable?: number; + } + + /** Represents break (e.g. ad break) included in main video. */ + declare export class Break { + constructor( + id: string, + breakClipIds: Array, + position: number, + ): Break; + /** + * List of ids of break clip that this break includes. + */ + breakClipIds: Array; + /** + * Duration of break in sec. + */ + duration?: number; + /** + * Unique id of break. + */ + id: string; + /** + * If true, indicates this is embedded break in main stream. + */ + isEmbedded?: boolean; + /** + * Whether break is watched. + * Sender can change color of progress bar marker corresponding to this break once this field changes from false to true, + * denoting that the end-user already watched this break. + */ + isWatched: boolean; + /** + * Where the break is located inside main video. -1 represents the end of main video. + */ + position: number; + } +} diff --git a/definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js b/definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js new file mode 100644 index 0000000000..2a11686dc5 --- /dev/null +++ b/definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js @@ -0,0 +1,52 @@ +import { TextTracksManager } from "cast.framework"; +import { StandbyChangedEvent } from "cast.framework.system"; +import { PlayerData } from "cast.framework.ui"; +import { BreakManager } from "cast.framework.breaks"; +import { MediaStatusEvent } from "cast.framework.events"; +import { Track, Break, MediaStatus, QueueData } from "cast.framework.messages"; + +// framework tests +const track = new Track(123, {}); +const ttm = new TextTracksManager({}); +ttm.addTracks(track); + +// $ExpectError +ttm.addTracks("should fail"); + +// system tests +const sce = new StandbyChangedEvent(true); +// $ExpectError +const wrongSce = new StandbyChangedEvent("error"); + +const result: boolean = sce.isStandby; +// $ExpectError +const failure: string = sce.isStandby; + +// ui tests +const pd = new PlayerData(); + +const cn: number = pd.currentBreakClipNumber; +// $ExpectError +const wrongCn: boolean = pd.currentBreakClipNumber; + +// breaks tests +const bm: BreakManager = new BreakManager(); +const brk1: Break = bm.getBreakById("123"); +// $ExpectError +const brk2: string = bm.getBreakById("123"); +// $ExpectError +const brk3: Break = bm.getBreakById(123); +// events tests + +const evt: MediaStatusEvent = new MediaStatusEvent(); +const ms: MediaStatus = evt.mediaStatus; +// $ExpectError +const ms: string = evt.mediaStatus; + +// messages tests +const qd = new QueueData("id", "name", "description", "mode"); +// $ExpectError +const wrongQd = new QueueData({}); +const name: string = qd.name; +// $ExpectError +const wrongName: number = qd.name; From 785cef3b273e05543afce544dcd6fccdc0ccccf8 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Mon, 12 Mar 2018 07:51:51 -0400 Subject: [PATCH 08/75] Adds a list of active maintainers to README (#1943) --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 133fa9a55a..1d563e3be3 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ working with this repository. The full list of commands is available at Installs libdefs from looking at your package.json. -If `package-specification` was specified, only that one libdef will be installed. +If `package-specification` was specified, only that one libdef will be installed. If the `--ignoreDeps` flag was specified, the libdefs for the specified deps will be ignored. i.e: `--ignoreDeps dev bundle peer`. ```bash @@ -107,3 +107,9 @@ on your local filesystem. Usually, the cache will automatically be updated after a short grace period during a libdef installation, but sometimes it is useful to do this update manually. Use this command if you want to download the most recent definitions into the cache for yourself. + +## Active Maintenance Team + +[![Andrew Smith](https://github.com/andrewsouthpaw.png?size=100)](https://github.com/andrewsouthpaw) | [![Georges-Antoine Assi](https://github.com/gantoine.png?size=100)](https://github.com/gantoine) | [![Ville Saukkonen](https://github.com/villesau.png?size=100)](https://github.com/villesau) +:---:|:---:|:---: +[@AndrewSouthpaw](https://github.com/andrewsouthpaw) | [@GAntoine](https://github.com/gantoine) | [@villesau](https://github.com/villesau) From cee06eb274624db42dab9163005b5d7f71c1f148 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Mon, 12 Mar 2018 08:14:40 -0400 Subject: [PATCH 09/75] Removes describe and it from global scopes (#1942) * Removes describe and it from global scopes * Add to global scope under other object * Move tdd framework to definitions util folder --- CONTRIBUTING.md | 20 ++++++++++++++- cli/src/commands/runTests.js | 27 ++++++++++++++++----- definitions/{ => __util__}/tdd_framework.js | 9 +++++-- 3 files changed, 47 insertions(+), 9 deletions(-) rename definitions/{ => __util__}/tdd_framework.js (70%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d2614458b..4da5aeb48a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -193,9 +193,11 @@ declare module "MyModule" { ### Use `describe` and `it` blocks to limit scope -You can use `describe` and `it` verbs, much like you do in Mocha/Jest/whatever, to write descriptive tests and limit scope. These are available on the global scope, so you don't need to import anything. (Note that they don't actually run tests, they're just sugar to limit scope and emulate the TDD language with which we're all familiar). +You can use `describe` and `it` verbs, much like you do in Mocha/Jest/whatever, to write descriptive tests and limit scope. These are available under 'flow-typed-test'. (Note that they don't actually run tests, they're just sugar to limit scope and emulate the TDD language with which we're all familiar). ```js +import { describe, it } from 'flow-typed-test'; + describe('#someFunction', () => { it('should do something', () => { const a: number = 1; @@ -206,3 +208,19 @@ describe('#someFunction', () => { const a: number = 'foo'; }) ``` + +`describe` or `it` have the potential of causing collisions. In the event of a name collision, import them under new names. + +```js +import { describe as foo, it as bar } from 'flow-typed-test'; + +foo('#someFunction', () => { + bar('should do something', () => { + const a: number = 1; + }); + + // you can also do type checks outside an it statement + //$ExpectError + const a: number = 'foo'; +}) +``` diff --git a/cli/src/commands/runTests.js b/cli/src/commands/runTests.js index 291e2d7703..f36b45705a 100644 --- a/cli/src/commands/runTests.js +++ b/cli/src/commands/runTests.js @@ -300,12 +300,18 @@ async function getCachedFlowBinVersions( return versions.map(version => `v${version}`); } -async function writeFlowConfig(testDirPath, libDefPath, includeWarnings) { +async function writeFlowConfig( + repoDirPath, + testDirPath, + libDefPath, + includeWarnings, +) { const destFlowConfigPath = path.join(testDirPath, '.flowconfig'); + const flowConfigData = [ '[libs]', path.basename(libDefPath), - '../../../definitions/tdd_framework.js', + path.join(repoDirPath, '..', '__util__', 'tdd_framework.js'), '', '[options]', 'suppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$ExpectError', @@ -422,6 +428,7 @@ async function testLowestCapableFlowVersion( } async function findLowestCapableFlowVersion( + repoDirPath, orderedFlowVersions, lowestFlowVersionRan, testDirPath, @@ -437,13 +444,13 @@ async function findLowestCapableFlowVersion( const higherLowVersions = lowerFlowVersionsToRun.filter(flowVer => semver.gte(flowVer, '0.53.0'), ); - await writeFlowConfig(testDirPath, libDefPath, true); + await writeFlowConfig(repoDirPath, testDirPath, libDefPath, true); const lowestOfHigherVersions = await testLowestCapableFlowVersion( higherLowVersions, testDirPath, lowestFlowVersionRan, ); - await writeFlowConfig(testDirPath, libDefPath, false); + await writeFlowConfig(repoDirPath, testDirPath, libDefPath, false); return await testLowestCapableFlowVersion( lowerLowVersions, testDirPath, @@ -468,6 +475,7 @@ async function removeTrashFromBinDir() { * directory. */ async function runTestGroup( + repoDirPath: string, testGroup: TestGroup, numberOfFlowVersions: number = 15, errors = [], @@ -550,14 +558,19 @@ async function runTestGroup( semver.gte(flowVer, '0.53.0'), ); - await writeFlowConfig(testDirPath, testGroup.libDefPath, false); + await writeFlowConfig( + repoDirPath, + testDirPath, + testGroup.libDefPath, + false, + ); const lowerVersionErrors = await runFlowTypeDefTests( lowerVersions, testGroup.id, testDirPath, ); - await writeFlowConfig(testDirPath, testGroup.libDefPath, true); + await writeFlowConfig(repoDirPath, testDirPath, testGroup.libDefPath, true); const higherVersionErrors = await runFlowTypeDefTests( higherVersions, testGroup.id, @@ -566,6 +579,7 @@ async function runTestGroup( errors.push(...higherVersionErrors, ...lowerVersionErrors); const lowestCapableFlowVersion = await findLowestCapableFlowVersion( + repoDirPath, orderedFlowVersions, lowestFlowVersionRan, testDirPath, @@ -622,6 +636,7 @@ async function runTests( while (testGroups.length > 0) { const testGroup = testGroups.shift(); const testGroupErrors = await runTestGroup( + repoDirPath, testGroup, numberOfFlowVersions, ); diff --git a/definitions/tdd_framework.js b/definitions/__util__/tdd_framework.js similarity index 70% rename from definitions/tdd_framework.js rename to definitions/__util__/tdd_framework.js index b154110305..3b354c2353 100644 --- a/definitions/tdd_framework.js +++ b/definitions/__util__/tdd_framework.js @@ -6,6 +6,8 @@ * * Usage: * + * import { describe, it } from 'flow-typed-test'; + * * describe('#someFunction', () => { * it('should do something', () => { * // test... @@ -17,5 +19,8 @@ * It is set up such that you don't need to import these functions, you can just use them naturally as if they were * available in the global scope. */ -export const describe = (label: string, fn: (...any) => any): void => { fn() } -export const it = (label: string, fn: (...any) => any): void => { fn() } + +declare module 'flow-typed-test' { + declare export function describe(label: string, fn: (...any) => void): void; + declare export function it(label: string, fn: (...any) => void): void; +} From b8dd3c3a2040ff2701e1de7b8502f3bcd1459002 Mon Sep 17 00:00:00 2001 From: "Alex Rattray (Stripe Acct)" Date: Mon, 12 Mar 2018 11:37:30 -0700 Subject: [PATCH 10/75] Jest: type `objectContaining` and peers as if they returned their described types (#1941) --- .../jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js index 0eee978242..f76d623d59 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js @@ -556,12 +556,12 @@ declare var expect: { assertions(expectedAssertions: number): void, hasAssertions(): void, any(value: mixed): JestAsymmetricEqualityType, - anything(): void, - arrayContaining(value: Array): void, - objectContaining(value: Object): void, + anything(): any, + arrayContaining(value: Array): Array, + objectContaining(value: Object): Object, /** Matches any received string that contains the exact expected string. */ - stringContaining(value: string): void, - stringMatching(value: string | RegExp): void + stringContaining(value: string): string, + stringMatching(value: string | RegExp): string }; // TODO handle return type @@ -578,14 +578,14 @@ declare var jest: JestObjectType; declare var jasmine: { DEFAULT_TIMEOUT_INTERVAL: number, any(value: mixed): JestAsymmetricEqualityType, - anything(): void, - arrayContaining(value: Array): void, + anything(): any, + arrayContaining(value: Array): Array, clock(): JestClockType, createSpy(name: string): JestSpyType, createSpyObj( baseName: string, methodNames: Array ): { [methodName: string]: JestSpyType }, - objectContaining(value: Object): void, - stringMatching(value: string): void + objectContaining(value: Object): Object, + stringMatching(value: string): string }; From ca09058fe153051533200d90a8f7b54af28c6aa3 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 13 Mar 2018 07:24:49 -0700 Subject: [PATCH 11/75] Add type definition for re-reselect based on reselect's definition (#1951) --- .../flow_v0.66.x-/re-reselect_v1.x.x.js | 867 ++++++++++++++++++ .../test_re-reselect_1.x.x.js | 101 ++ 2 files changed, 968 insertions(+) create mode 100644 definitions/npm/re-reselect_v1.x.x/flow_v0.66.x-/re-reselect_v1.x.x.js create mode 100644 definitions/npm/re-reselect_v1.x.x/test_re-reselect_1.x.x.js diff --git a/definitions/npm/re-reselect_v1.x.x/flow_v0.66.x-/re-reselect_v1.x.x.js b/definitions/npm/re-reselect_v1.x.x/flow_v0.66.x-/re-reselect_v1.x.x.js new file mode 100644 index 0000000000..9b9bdb70ad --- /dev/null +++ b/definitions/npm/re-reselect_v1.x.x/flow_v0.66.x-/re-reselect_v1.x.x.js @@ -0,0 +1,867 @@ +declare module "re-reselect" { + declare type Selector<-TState, TProps, TResult> = + (state: TState, props: TProps, ...rest: any[]) => TResult + + declare type SelectorCreator = + ((state: TState, props: TProps) => string | number) => Selector + + + declare type CreateCachedSelector = { + ( + selector1: Selector, + resultFunc: (arg1: T1) => TResult + ): SelectorCreator, + ( + selectors: [Selector], + resultFunc: (arg1: T1) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + resultFunc: (arg1: T1, arg2: T2) => TResult + ): SelectorCreator, + ( + selectors: [Selector, Selector], + resultFunc: (arg1: T1, arg2: T2) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + resultFunc: (arg1: T1, arg2: T2, arg3: T3) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector + ], + resultFunc: (arg1: T1, arg2: T2, arg3: T3) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + resultFunc: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector + ], + resultFunc: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + resultFunc: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6 + ) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6 + ) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7 + ) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7 + ) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8 + ) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8 + ) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9 + ) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9 + ) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + selector10: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10 + ) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10 + ) => TResult + ): SelectorCreator, + + ( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + selector10: Selector, + selector11: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11 + ) => TResult + ): SelectorCreator, + ( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11 + ) => TResult + ): SelectorCreator, + + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12 + >( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + selector10: Selector, + selector11: Selector, + selector12: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12 + ) => TResult + ): SelectorCreator, + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12 + >( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12 + ) => TResult + ): SelectorCreator, + + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13 + >( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + selector10: Selector, + selector11: Selector, + selector12: Selector, + selector13: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13 + ) => TResult + ): SelectorCreator, + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13 + >( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13 + ) => TResult + ): SelectorCreator, + + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14 + >( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + selector10: Selector, + selector11: Selector, + selector12: Selector, + selector13: Selector, + selector14: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13, + arg14: T14 + ) => TResult + ): SelectorCreator, + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14 + >( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13, + arg14: T14 + ) => TResult + ): SelectorCreator, + + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15 + >( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + selector10: Selector, + selector11: Selector, + selector12: Selector, + selector13: Selector, + selector14: Selector, + selector15: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13, + arg14: T14, + arg15: T15 + ) => TResult + ): SelectorCreator, + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15 + >( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13, + arg14: T14, + arg15: T15 + ) => TResult + ): SelectorCreator, + + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16 + >( + selector1: Selector, + selector2: Selector, + selector3: Selector, + selector4: Selector, + selector5: Selector, + selector6: Selector, + selector7: Selector, + selector8: Selector, + selector9: Selector, + selector10: Selector, + selector11: Selector, + selector12: Selector, + selector13: Selector, + selector14: Selector, + selector15: Selector, + selector16: Selector, + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13, + arg14: T14, + arg15: T15, + arg16: T16 + ) => TResult + ): SelectorCreator, + < + TState, + TProps, + TResult, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16 + >( + selectors: [ + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector, + Selector + ], + resultFunc: ( + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + arg5: T5, + arg6: T6, + arg7: T7, + arg8: T8, + arg9: T9, + arg10: T10, + arg11: T11, + arg12: T12, + arg13: T13, + arg14: T14, + arg15: T15, + arg16: T16 + ) => TResult + ): SelectorCreator + }; + + declare module.exports: CreateCachedSelector; +} diff --git a/definitions/npm/re-reselect_v1.x.x/test_re-reselect_1.x.x.js b/definitions/npm/re-reselect_v1.x.x/test_re-reselect_1.x.x.js new file mode 100644 index 0000000000..860572845d --- /dev/null +++ b/definitions/npm/re-reselect_v1.x.x/test_re-reselect_1.x.x.js @@ -0,0 +1,101 @@ +/* @flow */ +import createCachedSelector from "re-reselect"; + +// TEST: Should pass for 2 selectors given as arguments +type State = { + x: number, + y: number +}; + +const test1Selector = createCachedSelector( + (state: State) => state.x, + (state: State) => state.y, + (x, y) => { + return x + y; + } +)(() => 1) + +test1Selector({ x: 100, y: 200 }); +// $ExpectError invalid state +test1Selector({ x: 100 }); +// END TEST + +// TEST: Should pass for 2 selectors given as array +const test2Selector = createCachedSelector( + [(state: State) => state.x, (state: State) => state.y], + (x, y) => { + return x + y; + } +)(() => 2) + +test2Selector({ x: 100, y: 200 }); +// $ExpectError invalid state +test2Selector({ x: 100 }); +// END TEST + +// TEST: Should pass when selectors have additional Props argument +type TestProps = { + x: number +}; + +const test3Selector = createCachedSelector( + (state: State, props: TestProps) => state.x + props.x, + (state: State, props: TestProps) => state.y + props.x, + (x, y) => { + return x + y; + } +)((state, props) => props.x) + +test3Selector( + { x: 100, y: 200 }, + { x: 10 } +); +// $ExpectError invalid state +test3Selector({ x: 100 }, { x: 10 }); +// $ExpectError invalid props +test3Selector({ x: 100, y: 200 }, { y: 10 }); +// END TEST + +// TEST: Should work when using another selector as functions +{ + const simpleSelector = (state: State): string => "foo"; + const resultSelector = (arg: string): string => "foo"; + + const combinedSelector1 = createCachedSelector(simpleSelector, resultSelector)(() => 1); + const combinedSelector2: (state: State) => string = createCachedSelector( + combinedSelector1, + resultSelector + )(() => 2); + + combinedSelector1({ x: 100, y: 200 }) + // $ExpectError invalid state + combinedSelector1({ x: 100 }) +} +// END TEST + +// TEST: Should work when using more complex selectors as functions +{ + const resultFunc = (param1: string, param2: number): number => 42; + const simpleSelector = (state: State): string => "foo"; + const compoundSelector = createCachedSelector(simpleSelector, () => 42)(() => 1); + const selector = createCachedSelector( + simpleSelector, + compoundSelector, + resultFunc + )(() => 2); + + const result: number = selector({ x: 42, y: 42 }); + // $ExpectError invalid state + selector({ x: 42 }); +} +// END TEST + +// TEST: Should validate parameters based on the return values of nested +// selectors. +createCachedSelector( + (state: State) => state.x, + (state: State) => state.y, + // $ExpectError first argument will be a number, not a string. + (x: string, y: number) => "foo" +) +// END TEST From 39ff30c437fb7fc3a39e96c86284de45d9899b10 Mon Sep 17 00:00:00 2001 From: Deniz Dogan Date: Tue, 13 Mar 2018 15:29:16 +0100 Subject: [PATCH 12/75] Replace unmaintained "unzip" with drop-in replacement "unzipper" (#1957) --- cli/package.json | 2 +- cli/src/commands/runTests.js | 2 +- cli/yarn.lock | 109 ++++++++++++----------------------- 3 files changed, 40 insertions(+), 73 deletions(-) diff --git a/cli/package.json b/cli/package.json index 587241341d..fafce41ddb 100644 --- a/cli/package.json +++ b/cli/package.json @@ -36,7 +36,7 @@ "semver": "^5.5.0", "table": "^4.0.2", "through": "^2.3.8", - "unzip": "^0.1.11", + "unzipper": "^0.8.11", "which": "^1.3.0", "yargs": "^4.2.0" }, diff --git a/cli/src/commands/runTests.js b/cli/src/commands/runTests.js index f36b45705a..eafcd4846c 100644 --- a/cli/src/commands/runTests.js +++ b/cli/src/commands/runTests.js @@ -10,7 +10,7 @@ import {getDiff} from '../lib/git'; import got from 'got'; import * as semver from 'semver'; -import * as unzip from 'unzip'; +import * as unzip from 'unzipper'; import typeof Yargs from 'yargs'; import type {FlowVersion} from '../lib/flowVersion.js'; diff --git a/cli/yarn.lock b/cli/yarn.lock index 49cee8f170..060e9ee80b 100644 --- a/cli/yarn.lock +++ b/cli/yarn.lock @@ -986,11 +986,15 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +big-integer@^1.6.17: + version "1.6.26" + resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.26.tgz#3af1672fa62daf2d5ecafacf6e5aa0d25e02c1c8" + binary-extensions@^1.0.0: version "1.8.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" -"binary@>= 0.3.0 < 1": +binary@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" dependencies: @@ -1003,6 +1007,10 @@ block-stream@*: dependencies: inherits "~2.0.0" +bluebird@~3.4.1: + version "3.4.7" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3" + boom@2.x.x: version "2.10.1" resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" @@ -1059,6 +1067,10 @@ bser@^2.0.0: dependencies: node-int64 "^0.4.0" +buffer-indexof-polyfill@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.1.tgz#a9fb806ce8145d5428510ce72f278bb363a638bf" + buffer-shims@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" @@ -1442,6 +1454,12 @@ domexception@^1.0.0: dependencies: webidl-conversions "^4.0.2" +duplexer2@~0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" + dependencies: + readable-stream "^2.0.2" + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" @@ -1822,15 +1840,6 @@ fstream-ignore@^1.0.5, fstream-ignore@~1.0.5: inherits "2" minimatch "^3.0.0" -"fstream@>= 0.1.30 < 1": - version "0.1.31" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-0.1.31.tgz#7337f058fbbbbefa8c9f561a28cab0849202c988" - dependencies: - graceful-fs "~3.0.2" - inherits "~2.0.0" - mkdirp "0.5" - rimraf "2" - fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: version "1.0.10" resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.10.tgz#604e8a92fe26ffd9f6fae30399d4984e1ab22822" @@ -1995,12 +2004,6 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" -graceful-fs@~3.0.2: - version "3.0.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - dependencies: - natives "^1.1.0" - "graceful-readlink@>= 1.0.0": version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" @@ -2379,10 +2382,6 @@ is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -2893,6 +2892,10 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +listenercount@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/listenercount/-/listenercount-1.0.1.tgz#84c8a72ab59c4725321480c975e6508342e70937" + load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -2953,13 +2956,6 @@ makeerror@1.0.x: dependencies: tmpl "1.0.x" -"match-stream@>= 0.0.2 < 1": - version "0.0.2" - resolved "https://registry.yarnpkg.com/match-stream/-/match-stream-0.0.2.tgz#99eb050093b34dffade421b9ac0b410a9cfa17cf" - dependencies: - buffers "~0.1.1" - readable-stream "~1.0.0" - md5@^2.1.0: version "2.2.1" resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9" @@ -3058,7 +3054,7 @@ minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" -mkdirp@0.5, "mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.1: +"mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -3084,10 +3080,6 @@ nan@^2.3.0: version "2.4.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.4.0.tgz#fb3c59d45fe4effe215f0b890f8adf6eb32d2232" -natives@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31" - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -3292,10 +3284,6 @@ output-file-sync@^1.1.2: mkdirp "^0.5.1" object-assign "^4.1.0" -"over@>= 0.0.5 < 1": - version "0.0.5" - resolved "https://registry.yarnpkg.com/over/-/over-0.0.5.tgz#f29852e70fd7e25f360e013a8ec44c82aedb5708" - p-cancelable@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" @@ -3452,15 +3440,6 @@ pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" -"pullstream@>= 0.4.1 < 1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/pullstream/-/pullstream-0.4.1.tgz#d6fb3bf5aed697e831150eb1002c25a3f8ae1314" - dependencies: - over ">= 0.0.5 < 1" - readable-stream "~1.0.31" - setimmediate ">= 1.0.2 < 2" - slice-stream ">= 1.0.0 < 2" - punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" @@ -3545,16 +3524,7 @@ readable-stream@^2.0.1, readable-stream@^2.1.4, readable-stream@^2.2.2: string_decoder "~1.0.3" util-deprecate "~1.0.1" -readable-stream@~1.0.0, readable-stream@~1.0.31: - version "1.0.34" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@~2.1.4: +readable-stream@~2.1.4, readable-stream@~2.1.5: version "2.1.5" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" dependencies: @@ -3863,7 +3833,7 @@ set-immediate-shim@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" -"setimmediate@>= 1.0.1 < 2", "setimmediate@>= 1.0.2 < 2": +setimmediate@~1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" @@ -3899,12 +3869,6 @@ slice-ansi@1.0.0: dependencies: is-fullwidth-code-point "^2.0.0" -"slice-stream@>= 1.0.0 < 2": - version "1.0.0" - resolved "https://registry.yarnpkg.com/slice-stream/-/slice-stream-1.0.0.tgz#5b33bd66f013b1a7f86460b03d463dec39ad3ea0" - dependencies: - readable-stream "~1.0.31" - sntp@1.x.x: version "1.0.9" resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" @@ -4285,16 +4249,19 @@ universalify@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.0.tgz#9eb1c4651debcc670cc94f1a75762332bb967778" -unzip@^0.1.11: - version "0.1.11" - resolved "https://registry.yarnpkg.com/unzip/-/unzip-0.1.11.tgz#89749c63b058d7d90d619f86b98aa1535d3b97f0" +unzipper@^0.8.11: + version "0.8.11" + resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.8.11.tgz#894383dc6b4bdab944e446f665a82d40d167fbd4" dependencies: - binary ">= 0.3.0 < 1" - fstream ">= 0.1.30 < 1" - match-stream ">= 0.0.2 < 1" - pullstream ">= 0.4.1 < 1" - readable-stream "~1.0.31" - setimmediate ">= 1.0.1 < 2" + big-integer "^1.6.17" + binary "~0.3.0" + bluebird "~3.4.1" + buffer-indexof-polyfill "~1.0.0" + duplexer2 "~0.1.4" + fstream "~1.0.10" + listenercount "~1.0.1" + readable-stream "~2.1.5" + setimmediate "~1.0.4" url-parse-lax@^1.0.0: version "1.0.0" From 302430654ca3b33ed4897eb90dab8da8b7b93c83 Mon Sep 17 00:00:00 2001 From: Dimitri DO BAIRRO Date: Tue, 13 Mar 2018 15:30:58 +0100 Subject: [PATCH 13/75] Adding @sengrid/mail definition (#1949) * feat(npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js) definition created * feat(npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/test_mail_v6.x.x.js) test created * feat(npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/test_mail_v6.x.x.js) send function uncommented * feat(npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js) export type changed * chore(npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/test_mail_v6.x.x.js) many tests added * Added statements expected to fail --- .../mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js | 138 ++++++++++++++++++ .../flow_v0.30.x-/test_mail_v6.x.x.js | 121 +++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js create mode 100644 definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/test_mail_v6.x.x.js diff --git a/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js b/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js new file mode 100644 index 0000000000..17728fb4f3 --- /dev/null +++ b/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js @@ -0,0 +1,138 @@ +declare module '@sendgrid/mail' { + + declare class ResponseError extends Error { + code: number; + message: string; + response: { + headers: { [key: string]: string; }; + body: string; + }; + } + + declare interface PersonalizationData { + to: EmailData | EmailData[], + cc?: EmailData | EmailData[], + bcc?: EmailData | EmailData[], + subject?: string; + headers?: { [key: string]: string }; + substitutions?: { [key: string]: string }; + customArgs?: { [key: string]: string }; + sendAt?: number; + } + + declare interface AttachmentData { + content: string; + filename: string; + type?: string; + disposition?: string; + contentId?: string; + } + + declare interface ASMOptions { + groupId: number; + groupsToDisplay?: number[]; + } + + declare interface MailSettings { + bcc?: { + enable?: boolean; + email?: string; + }; + bypassListManagement?: { + enable?: boolean; + }; + footer?: { + enable?: boolean; + text?: string; + html?: string; + }; + sandboxMode?: { + enable?: boolean; + }; + spamCheck?: { + enable?: boolean; + threshold?: number; + postToUrl?: string; + }; + } + + declare interface TrackingSettings { + clickTracking?: { + enable?: boolean; + enableText?: boolean; + }; + openTracking?: { + enable?: boolean; + substitutionTag?: string; + }; + subscriptionTracking?: { + enable?: boolean; + text?: string; + html?: string; + substitutionTag?: string; + }; + ganalytics?: { + enable?: boolean; + utmSource?: string; + utmMedium?: string; + utmTerm?: string; + utmContent?: string; + utmCampaign?: string; + }; + } + + declare type EmailData = string | { name?: string; email: string; }; + + declare interface MailContent { + type: string; + value: string; + } + + declare export type MailData = { + to?: EmailData | EmailData[], + cc?: EmailData | EmailData[], + bcc?: EmailData | EmailData[], + + from: EmailData, + replyTo?: EmailData, + + sendAt?: number, + + subject?: string, + text?: string, + html?: string, + content?: MailContent[], + templateId?: string, + + personalizations?: PersonalizationData[], + attachments?: AttachmentData[], + + ipPoolName?: string, + batchId?: string, + + sections?: { [key: string]: string }, + headers?: { [key: string]: string }, + + categories?: string[], + category?: string, + + customArgs?: { [key: string]: any }, + asm?: ASMOptions, + + mailSettings?: MailSettings, + trackingSettings?: TrackingSettings, + + substitutions?: { [key: string]: string }, + substitutionWrappers?: string[], + + isMultiple?: boolean, + } + + declare class MailService { + setApiKey(apiKey: string): void; + setSubstitutionWrappers(left: string, right: string): void; + send(data: MailData | MailData[], isMultiple?: boolean, cb?: (err: Error | ResponseError, result: [http$ClientRequest, {}]) => void): Promise<[http$ClientRequest, {}]>; + } + + declare export default MailService & { MailService: MailService }; +} diff --git a/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/test_mail_v6.x.x.js b/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/test_mail_v6.x.x.js new file mode 100644 index 0000000000..7d9712015d --- /dev/null +++ b/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/test_mail_v6.x.x.js @@ -0,0 +1,121 @@ +import mail from '@sendgrid/mail'; + +mail.setApiKey('myApiKey'); + +// CC, BCC and Reply To +mail.send({ + to: 'dimitri.dobairro@example.org', + cc: 'clement.mondion@example.org', + bcc: ['me@example.org', 'you@example.org'], + from: 'sender@example.org', + replyTo: 'othersender@example.org', + subject: 'Hello world', + text: 'Hello plain world!', + html: '

Hello HTML world!

', +}); + +// Send a Single Email to Multiple Recipients +mail.send({ + to: ['dimitri.dobairro@example.com', 'clark.kent@example.com'], + replyTo: 'clement.mondion@example.com', + from: 'john.doe@example.com', + subject: 'Sending with SendGrid is Fun', + text: 'and easy to do anywhere, even with Node.js', + html: 'and easy to do anywhere, even with Node.js', +}); + +// Send Multiple Emails to Multiple Recipients +mail.send([ + { + to: 'dimitri.dobairro@example.org', + from: 'clement.mondion@example.org', + subject: 'Hello recipient 1', + text: 'Hello plain world!', + html: '

Hello HTML world!

', + }, + { + to: 'john.doe@example.org', + from: 'other-sender@example.org', + subject: 'Hello recipient 2', + text: 'Hello other plain world!', + html: '

Hello other HTML world!

', + }, +]); + +// Manually Providing Content +mail.send({ + to: 'dimitri.dobairro@example.org', + from: 'sender@example.org', + subject: 'Hello manual content', + content: [ + { + type: 'text/html', + value: '

Hello HTML world!

', + }, + { + type: 'text/plain', + value: 'Hello plain world!', + }, + ], +}); + +// Attachments +mail.send({ + to: 'dimitri.dobairro@example.org', + from: 'clement.mondion@example.org', + subject: 'Hello attachment', + html: '

Here’s an attachment for you!

', + attachments: [ + { + content: 'SSdtIGEgZnVsbCBzdGFjayBKUyBkZXZlbG9wZXIuIA0KDQpSZWdhcmRzLA0KQHJpbWl0aSw=', + filename: 'some-attachment.txt', + type: 'plain/text', + disposition: 'attachment', + contentId: 'mytext' + }, + ], +}); + +// Specifying Custom Headers +mail.send({ + to: 'dimitri.dobairro@example.org', + from: 'clement.mondion@example.org', + subject: 'Hello custom header', + html: '

Some email content

', + headers: { + 'X-CustomHeader': 'Custom header value', + }, +}); + +// Specifying Custom Headers +mail.send({ + to: 'dimitri.dobairro@example.org', + from: 'clement.mondion@example.org', + subject: 'Hello custom header', + html: '

Some email content

', + headers: { + 'X-CustomHeader': 'Custom header value', + }, +}); + +// Missing options +// $ExpectError +mail.send(); + +// Empty options hash +// $ExpectError +mail.send({}); + +// Incorrect options +mail.send({ + // $ExpectError + from: 0, +}); + +// Missing from address +// $ExpectError +mail.send({ + to: 'dimitri.dobairro@example.org', + subject: 'Hello attachment', + html: '

Here’s an attachment for you!

', +}); From 7b9f6d2713aaf2d3c199b867efc6c363e4a34b29 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Tue, 13 Mar 2018 16:21:18 +0100 Subject: [PATCH 14/75] Support jest-enzyme version 5 (#1922) * Support jest-enzyme version 5.0.0 * Update jest_v20.x.x types to match jest_v22.x.x --- .../jest_v20.x.x/flow_v0.39.x-/jest_v20.x.x.js | 12 +++++++----- .../flow_v0.39.x-/test_jest-v20.x.x.js | 16 ++++++++++++++-- .../jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js | 8 +++++--- .../flow_v0.39.x-/test_jest-v22.x.x.js | 15 +++++++++++++++ 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/definitions/npm/jest_v20.x.x/flow_v0.39.x-/jest_v20.x.x.js b/definitions/npm/jest_v20.x.x/flow_v0.39.x-/jest_v20.x.x.js index 3062f1946d..4de82d31d2 100644 --- a/definitions/npm/jest_v20.x.x/flow_v0.39.x-/jest_v20.x.x.js +++ b/definitions/npm/jest_v20.x.x/flow_v0.39.x-/jest_v20.x.x.js @@ -114,23 +114,25 @@ type JestPromiseType = { * Plugin: jest-enzyme */ type EnzymeMatchersType = { - toExist(): void, toBeChecked(): void, toBeDisabled(): void, + toBeEmpty(): void, toBeEmptyRender(): void, + toBePresent(): void, toContainReact(element: React$Element): void, + toExist(): void, toHaveClassName(className: string): void, toHaveHTML(html: string): void, + toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), toHaveRef(refName: string): void, - toHaveProp(propKey: string | Object, propValue?: any): void, - toHaveState(stateKey: string | Object, stateValue?: any): void, - toHaveStyle(styleKey: string | Object, styleValue?: any): void, + toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), + toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), toHaveTagName(tagName: string): void, toHaveText(text: string): void, toIncludeText(text: string): void, toHaveValue(value: any): void, toMatchElement(element: React$Element): void, - toMatchSelector(selector: string): void, + toMatchSelector(selector: string): void }; type JestExpectType = { diff --git a/definitions/npm/jest_v20.x.x/flow_v0.39.x-/test_jest-v20.x.x.js b/definitions/npm/jest_v20.x.x/flow_v0.39.x-/test_jest-v20.x.x.js index 5f03b3a162..970b7427bd 100644 --- a/definitions/npm/jest_v20.x.x/flow_v0.39.x-/test_jest-v20.x.x.js +++ b/definitions/npm/jest_v20.x.x/flow_v0.39.x-/test_jest-v20.x.x.js @@ -203,16 +203,20 @@ expect(wrapper).toBeChecked(); expect(wrapper).toBeDisabled(); -expect(wrapper).toExist(); +expect(wrapper).toBeEmpty(); expect(wrapper).toBeEmptyRender(); +expect(wrapper).toBePresent(); + expect(wrapper).toContainReact(); // $ExpectError expect(wrapper).toContainReact(); // $ExpectError expect(wrapper).toContainReact("string"); +expect(wrapper).toExist(); + expect(wrapper).toHaveClassName("class"); // $ExpectError expect(wrapper).toHaveClassName(); @@ -227,11 +231,13 @@ expect(wrapper).toHaveHTML(true); expect(wrapper).toHaveProp("test"); expect(wrapper).toHaveProp("test", "test"); -expect(wrapper).toHaveProp({ test: "test" }); // $ExpectError expect(wrapper).toHaveProp(); // $ExpectError expect(wrapper).toHaveProp(true); +expect(wrapper).toHaveProp({ test: "test" }); +// $ExpectError +expect(wrapper).toHaveProp({ test: "test" }, "test"); expect(wrapper).toHaveRef("test"); // $ExpectError @@ -242,6 +248,9 @@ expect(wrapper).toHaveRef(true); expect(wrapper).toHaveState("test"); expect(wrapper).toHaveState("test", "test"); expect(wrapper).toHaveState({ test: "test" }); +// $ExpectError +expect(wrapper).toHaveState({ test: "test" }, "test"); + // $ExpectError expect(wrapper).toHaveState(); // $ExpectError @@ -250,6 +259,9 @@ expect(wrapper).toHaveState(true); expect(wrapper).toHaveStyle("color"); expect(wrapper).toHaveStyle("color", "#ccc"); expect(wrapper).toHaveStyle({ color: "#ccc" }); +// $ExpectError +expect(wrapper).toHaveStyle({ color: "#ccc" }, "test"); + // $ExpectError expect(wrapper).toHaveStyle(); // $ExpectError diff --git a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js index f76d623d59..393b9b9c81 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js @@ -123,14 +123,16 @@ type EnzymeMatchersType = { toBeChecked(): void, toBeDisabled(): void, toBeEmpty(): void, + toBeEmptyRender(): void, toBePresent(): void, toContainReact(element: React$Element): void, + toExist(): void, toHaveClassName(className: string): void, toHaveHTML(html: string): void, - toHaveProp(propKey: string, propValue?: any): void, + toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), toHaveRef(refName: string): void, - toHaveState(stateKey: string, stateValue?: any): void, - toHaveStyle(styleKey: string, styleValue?: any): void, + toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), + toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), toHaveTagName(tagName: string): void, toHaveText(text: string): void, toIncludeText(text: string): void, diff --git a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js index 018de69cc2..eadb5923c8 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js @@ -221,6 +221,8 @@ expect(wrapper).toBeDisabled(); expect(wrapper).toBeEmpty(); +expect(wrapper).toBeEmptyRender(); + expect(wrapper).toBePresent(); expect(wrapper).toContainReact(); @@ -229,6 +231,8 @@ expect(wrapper).toContainReact(); // $ExpectError expect(wrapper).toContainReact("string"); +expect(wrapper).toExist(); + expect(wrapper).toHaveClassName("class"); // $ExpectError expect(wrapper).toHaveClassName(); @@ -247,6 +251,9 @@ expect(wrapper).toHaveProp("test", "test"); expect(wrapper).toHaveProp(); // $ExpectError expect(wrapper).toHaveProp(true); +expect(wrapper).toHaveProp({ test: "test" }); +// $ExpectError +expect(wrapper).toHaveProp({ test: "test" }, "test"); expect(wrapper).toHaveRef("test"); // $ExpectError @@ -256,6 +263,10 @@ expect(wrapper).toHaveRef(true); expect(wrapper).toHaveState("test"); expect(wrapper).toHaveState("test", "test"); +expect(wrapper).toHaveState({ test: "test" }); +// $ExpectError +expect(wrapper).toHaveState({ test: "test" }, "test"); + // $ExpectError expect(wrapper).toHaveState(); // $ExpectError @@ -263,6 +274,10 @@ expect(wrapper).toHaveState(true); expect(wrapper).toHaveStyle("color"); expect(wrapper).toHaveStyle("color", "#ccc"); +expect(wrapper).toHaveStyle({ color: "#ccc" }); +// $ExpectError +expect(wrapper).toHaveStyle({ color: "#ccc" }, "test"); + // $ExpectError expect(wrapper).toHaveStyle(); // $ExpectError From 97a8f862fc7fe23520a341de6228520b2a81ebd7 Mon Sep 17 00:00:00 2001 From: Aleksander Heintz Date: Tue, 13 Mar 2018 18:43:40 +0100 Subject: [PATCH 15/75] Add amplitude-js types (#1953) --- .../flow_v0.47.x-/amplitude-js_v4.x.x.js | 352 ++++++++++++++++++ .../flow_v0.47.x-/test_amplitude-js_v4.x.x.js | 224 +++++++++++ 2 files changed, 576 insertions(+) create mode 100644 definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/amplitude-js_v4.x.x.js create mode 100644 definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/test_amplitude-js_v4.x.x.js diff --git a/definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/amplitude-js_v4.x.x.js b/definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/amplitude-js_v4.x.x.js new file mode 100644 index 0000000000..b5202d16b8 --- /dev/null +++ b/definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/amplitude-js_v4.x.x.js @@ -0,0 +1,352 @@ +// @flow + +declare module 'amplitude-js' { + declare type SimplePropertyValue = string | number; + declare type PropertyValue = SimplePropertyValue | $ReadOnlyArray; + declare type PropertyObject = { +[name: string]: PropertyValue }; + declare type CompoundPropertyValue = PropertyValue | PropertyObject; + declare type EventCallback = (responseCode: number, responseBody: string) => mixed; + declare type GroupsMap = { +[name: string]: string | $ReadOnlyArray }; + + declare type AmplitudeConfig = { + +batchEvents?: boolean, + +cookieExpiration?: number, + +cookieName?: string, + +deviceId?: string, + +deviceIdFromUrlParam?: boolean, + +domain?: string, + +eventUploadPeriodMillis?: number, + +eventUploadThreshold?: number, + +forceHttps?: boolean, + +includeGclid?: boolean, + +includeReferrer?: boolean, + +includeUtm?: boolean, + +language?: string, + +logLevel?: string, + +optOut?: boolean, + +platform?: string, + +saveEvents?: boolean, + +savedMaxCount?: number, + +saveParamsReferrerOncePerSession?: boolean, + +sessionTimeout?: number, + +uploadBatchSize?: number, + }; + + /** + * Identify API. Identify objects are a wrapper for user property operations. + * Each method adds a user property operation to the Identify object, and returns the same Identify object, + * allowing you to chain multiple method calls together. + * Note: if the same user property is used in multiple operations on a single Identify object, + * only the first operation on that property will be saved, and the rest will be ignored. + * See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#user-properties-and-user-property-operations} + * for more information on the Identify API and user property operations. + */ + declare export class Identify { + /** + * @public + * @constructor + */ + constructor(): Identify; + + /** + * Increment a user property by a given value (can also be negative to decrement). + * If the user property does not have a value set yet, it will be initialized to 0 before being incremented. + * @public + * @param {string} property The user property key. + * @param {number} value The amount by which to increment the user property. + * @return {Identify} Returns the same Identify object, allowing you to chain multiple method calls together. + */ + add(property: string, value: number): Identify; + + /** + * Append a value or values to a user property. + * If the user property does not have a value set yet, + * it will be initialized to an empty list before the new values are appended. + * If the user property has an existing value and it is not a list, + * the existing value will be converted into a list with the new values appended. + * @public + * @param {string} property The user property key. + * @param {number|string|list} value A value or values to append. + * @return {Identify} Returns the same Identify object, allowing you to chain multiple method calls together. + */ + append(property: string, value: PropertyValue): Identify; + + /** + * Prepend a value or values to a user property. + * If the user property does not have a value set yet, + * it will be initialized to an empty list before the new values are prepended. + * If the user property has an existing value and it is not a list, + * the existing value will be converted into a list with the new values prepended. + * @public + * @param {string} property The user property key. + * @param {number|string|list} value A value or values to append. + * @return {Identify} Returns the same Identify object, allowing you to chain multiple method calls together. + */ + prepend(property: string, value: PropertyValue): Identify; + + /** + * Sets the value of a given user property. If a value already exists, it will be overwriten with the new value. + * @public + * @param {string} property The user property key. + * @param {number|string|list|object} value A value or values to append. + * @return {Identify} Returns the same Identify object, allowing you to chain multiple method calls together. + */ + set(property: string, value: CompoundPropertyValue): Identify; + + /** + * Sets the value of a given user property only once. Subsequent setOnce operations on that user property will be ignored; + * however, that user property can still be modified through any of the other operations. + * Useful for capturing properties such as 'initial_signup_date', 'initial_referrer', etc. + * @public + * @param {string} property The user property key. + * @param {number|string|list|object} value A value or values to append. + * @return {Identify} Returns the same Identify object, allowing you to chain multiple method calls together. + */ + setOnce(property: string, value: CompoundPropertyValue): Identify; + + /** + * Unset and remove a user property. This user property will no longer show up in a user's profile. + * @public + * @param {string} property The user property key. + * @return {Identify} Returns the same Identify object, allowing you to chain multiple method calls together. + */ + unset(property: string): Identify; + } + + /** + * Revenue API. Revenue objects are a wrapper for revenue data. + * Each method updates a revenue property in the Revenue object, and returns the same Revenue object, + * allowing you to chain multiple method calls together. + * Note: price is a required field to log revenue events. + * If quantity is not specified then defaults to 1. + * See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#tracking-revenue} for more information + * about logging Revenue. + */ + declare export class Revenue { + /** + * @public + * @constructor + */ + constructor(): Revenue; + + /** + * Set a value for the product identifer. + * @public + * @param {string} productId The value for the product identifier. Empty and invalid strings are ignored. + * @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together. + */ + setProductId(productId: string): Revenue; + + /** + * Set a value for the quantity. Note revenue amount is calculated as price * quantity. + * @public + * @param {number} quantity Integer value for the quantity. If not set, quantity defaults to 1. + * @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together. + */ + setQuantity(quantity?: number): Revenue; + + /** + * Set a value for the price. This field is required for all revenue being logged. + * Note revenue amount is calculated as price * quantity. + * @public + * @param {number} price Double value for the quantity. + * @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together. + */ + setPrice(price: number): Revenue; + + /** + * Set a value for the revenueType (for example purchase, cost, tax, refund, etc). + * @public + * @param {string} revenueType RevenueType to designate. + * @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together. + */ + setRevenueType(revenueType: string): Revenue; + + /** + * Set event properties for the revenue event. + * @public + * @param {object} eventProperties Revenue event properties to set. + * @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together. + */ + setEventProperties(eventProperties: PropertyObject): Revenue; + } + + /** + * AmplitudeClient SDK API. + * The Amplitude class handles creation of client instances, all you need to do is call `amplitude.getInstance()`. + */ + declare export interface AmplitudeClient { + +Identify: typeof Identify; + +Revenue: typeof Revenue; + + /** + * Initializes the Amplitude Javascript SDK with your apiKey and any optional configurations. + * This is required before any other methods can be called. + * @public + * @param {string} apiKey The API key for your app. + * @param {string} userId (optional) An identifier for this user. + * @param {object} config (optional) Configuration options. + * See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#configuration-options} for list of options and default values. + * @param {function} callback (optional) Provide a callback function to run after initialization is complete. + */ + init(apiKey: string, userId?: string | null, config?: AmplitudeConfig | null, callback?: (client: AmplitudeClient) => mixed): void; + + /** + * Returns true if a new session was created during initialization, otherwise false. + * @public + * @return {boolean} Whether a new session was created during initialization. + */ + isNewSession(): boolean; + + /** + * Returns the id of the current session. + * @public + * @return {number} Id of the current session. + */ + getSessionId(): number; + + /** + * Sets a customer domain for the amplitude cookie. Useful if you want to support cross-subdomain tracking. + * @public + * @param {string} domain The domain to set. + */ + setDomain(domain: string): void; + + /** + * Sets an identifier for the current user. + * @public + * @param {string} userId Identifier to set. Can be null. + */ + setUserId(userId: string | null): void; + + /** + * Add user to a group or groups. You need to specify a groupType and groupName(s). + * For example you can group people by their organization. + * In that case groupType is "orgId" and groupName would be the actual ID(s). + * groupName can be a string or an array of strings to indicate a user in multiple gruups. + * You can also call setGroup multiple times with different groupTypes to track multiple types of groups (up to 5 per app). + * Note: this will also set groupType: groupName as a user property. + * See the [SDK Readme]{@link https://github.com/amplitude/Amplitude-Javascript#setting-groups} for more information. + * @public + * @param {string} groupType The group type (ex: orgId). + * @param {string|list} groupName The name of the group (ex: 15), or a list of names of the groups. + */ + setGroup(groupType: string, groupName: string | $ReadOnlyArray): void; + + /** + * Sets whether to opt current user out of tracking. + * @public + * @param {boolean} enable If true then no events will be logged or sent. + */ + setOptOut(enable: boolean): void; + + /** + * Regenerates a new random deviceId for current user. Note: this is not recommended unless you know what you + * are doing. This can be used in conjunction with `setUserId(null)` to anonymize users after they log out. + * With a null userId and a completely new deviceId, the current user would appear as a brand new user in dashboard. + * This uses src/uuid.js to regenerate the deviceId. + * @public + */ + regenerateDeviceId(): void; + + /** + * Sets a custom deviceId for current user. Note: this is not recommended unless you know what you are doing + * (like if you have your own system for managing deviceIds). Make sure the deviceId you set is sufficiently unique + * (we recommend something like a UUID - see src/uuid.js for an example of how to generate) to prevent conflicts with other devices in our system. + * @public + * @param {string} deviceId Custom deviceId for current user. + */ + setDeviceId(deviceId: string): void; + + /** + * Sets user properties for the current user. + * @public + * @param {object} userProperties Object with string keys and values for the user properties to set. + */ + setUserProperties(userProperties: PropertyObject): void; + + /** + * Clear all of the user properties for the current user. Note: clearing user properties is irreversible! + * @public + */ + clearUserProperties(): void; + + /** + * Send an identify call containing user property operations to Amplitude servers. + * See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#user-properties-and-user-property-operations} + * for more information on the Identify API and user property operations. + * @param {Identify} identify The Identify object containing the user property operations to send. + * @param {function} callback (optional) Callback function to run when the identify event has been sent. + */ + identify(identify: Identify, callback?: EventCallback): void; + + /** + * Set a versionName for your application. + * @public + * @param {string} versionName The version to set for your application. + */ + setVersionName(versionName: string): void; + + /** + * Log an event with eventType and eventProperties. + * @public + * @param {string} eventType The name of the event. + * @param {object} eventProperties (optional) An object with string keys and values for the event properties. + * @param {function} callback (optional) A callback function to run after the event is logged. + */ + logEvent(eventType: string, eventProperties?: PropertyObject | null, callback?: EventCallback): void; + + /** + * Log an event with eventType and eventProperties and a custom timestamp. + * @public + * @param {string} eventType The name of the event. + * @param {object} eventProperties (optional) An object with string keys and values for the event properties. + * @param {number} timestamp (optional) The custom timestamp as milliseconds since epoch. + * @param {function} callback (optional) A callback function to run after the event is logged. + */ + logEventWithTimestamp(eventType: string, eventProperties?: PropertyObject | null, timestamp?: number | null, callback?: EventCallback): void; + + /** + * Log an event with eventType, eventProperties, and groups. Use this to set event-level groups. + * Note: the group(s) set only apply for the specific event type being logged and does not persist on the user + * (unless you explicitly set it with setGroup). + * See the [SDK Readme]{@link https://github.com/amplitude/Amplitude-Javascript#setting-groups} for more information + * about groups and Count by Distinct on the Amplitude platform. + * @public + * @param {string} eventType The name of the event. + * @param {object} eventProperties (optional) An object with string keys and values for the event properties. + * @param {object} groups (optional) An object with string groupType: groupName values for the event being logged. + * @param {function} callback (optional) A callback function to run after the event is logged. + */ + logEventWithGroups(eventType: string, eventProperties?: PropertyObject | null, groups?: GroupsMap | null, callback?: EventCallback): void; + + /** + * Log revenue with Revenue interface. The new revenue interface allows for more revenue fields like + * revenueType and event properties. + * See [Readme]{@link https://github.com/amplitude/Amplitude-Javascript#tracking-revenue} + * for more information on the Revenue interface and logging revenue. + * @public + * @param {Revenue} revenue The revenue object containing the revenue data being logged. + */ + logRevenueV2(revenue: Revenue): void; + } + + /** + * Amplitude SDK API - instance manager. + */ + declare class Amplitude { + /** + * @public + * @constructor + */ + constructor(): Amplitude; + + +Identify: typeof Identify; + +Revenue: typeof Revenue; + + getInstance(name?: string): AmplitudeClient; + } + + declare export function getInstance(name?: string): AmplitudeClient; + declare export default Amplitude; +} diff --git a/definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/test_amplitude-js_v4.x.x.js b/definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/test_amplitude-js_v4.x.x.js new file mode 100644 index 0000000000..50f1369249 --- /dev/null +++ b/definitions/npm/amplitude-js_v4.x.x/flow_v0.47.x-/test_amplitude-js_v4.x.x.js @@ -0,0 +1,224 @@ +// @flow + +/* eslint-disable no-unused-vars, no-undef, no-console */ + +import amplitude, { Identify, Revenue } from 'amplitude-js'; +import type { AmplitudeClient } from 'amplitude-js'; + +/** + * Common instances + */ + +const client = amplitude.getInstance(); +const identify = new Identify(); +const revenue = new Revenue(); +const callback = (responseCode: number, responseBody: string) => void 0; + +/** + * ALL THE TESTS START FROM HERE + */ + +function getInstanceTest() { + (amplitude.getInstance(): AmplitudeClient); + (amplitude.getInstance('name'): AmplitudeClient); + + // $ExpectError: getInstance only accepts strings + amplitude.getInstance(5); + + // $ExpectError: getInstance only accepts strings + amplitude.getInstance(new Date()); +} + +function identifyTests() { + //* constructor + (new Identify(): Identify); + + const i: Identify = new Identify(); + + //* add + i.add('foo', 1); + i.add('bar', -10); + + // $ExpectError: add requies a name as first parameter + i.add(15, 21); + + // $ExpectError: add requies a number as second parameter + i.add('foo', 'bar'); + + //* append + i.append('foo', 1); + i.append('foo', [1]); + i.append('foo', 'bar'); + i.append('foo', ['bar']); + i.append('foo', [1, 'bar']); + + //* prepend + i.prepend('foo', 1); + i.prepend('foo', [1]); + i.prepend('foo', 'bar'); + i.prepend('foo', ['bar']); + i.prepend('foo', [1, 'bar']); + + //* set + i.set('foo', 1); + i.set('foo', [1]); + i.set('foo', 'bar'); + i.set('foo', ['bar']); + i.set('foo', [1, 'bar']); + i.set('foo', {}); + i.set('foo', { foo: 1 }); + i.set('foo', { foo: [1] }); + i.set('foo', { foo: 'foo' }); + i.set('foo', { foo: ['foo'] }); + i.set('foo', { foo: [1, 'foo'] }); + + //* setOnce + i.setOnce('foo', 1); + i.setOnce('foo', [1]); + i.setOnce('foo', 'bar'); + i.setOnce('foo', ['bar']); + i.setOnce('foo', [1, 'bar']); + i.setOnce('foo', {}); + i.setOnce('foo', { foo: 1 }); + i.setOnce('foo', { foo: [1] }); + i.setOnce('foo', { foo: 'foo' }); + i.setOnce('foo', { foo: ['foo'] }); + i.setOnce('foo', { foo: [1, 'foo'] }); + + //* unset + i.unset('foo'); +} + +function revenueTests() { + //* constructor + (new Revenue(): Revenue); + + const r: Revenue = new Revenue(); + + //* setProductId + r.setProductId('pid'); + + // $ExpectError: setProductId only accepts strings + r.setProductId(5); + + // $ExpectError: setProductId only accepts strings + r.setProductId(); + + //* setQuantity + r.setQuantity(5); + r.setQuantity(); + + // $ExpectError: setProductId only accepts numbers + r.setQuantity('foo'); + + //* setPrice + r.setPrice(15); + + // $ExpectError: setPrice only accepts numbers + r.setPrice(); + + // $ExpectError: setPrice only accepts numbers + r.setPrice('foo'); + + //* setRevenueType + r.setRevenueType('cost'); + + // $ExpectError: setRevenueType only accepts strings + r.setRevenueType(5); + + // $ExpectError: setRevenueType only accepts strings + r.setRevenueType(); + + //* setEventProperties + // $ExpectError: setEventProperties requires arguments + r.setEventProperties(); + r.setEventProperties({}); + r.setEventProperties({ foo: 1 }); + r.setEventProperties({ foo: [1] }); + r.setEventProperties({ foo: 'foo' }); + r.setEventProperties({ foo: ['foo'] }); + r.setEventProperties({ foo: [1, 'foo'] }); +} + +function amplitudeClientTests() { + const client: AmplitudeClient = amplitude.getInstance(); + + //* Identify + (client.Identify: typeof Identify); + + //* Revenue + (client.Revenue: typeof Revenue); + + //* init + client.init('key'); + client.init('key', 'uid'); + client.init('key', null, { batchEvents: false }); + client.init('key', 'uid', null, function(c: AmplitudeClient) {}); + + //* isNewSession + (client.isNewSession(): boolean); + + //* getSessionId + (client.getSessionId(): number); + + //* setDomain + client.setDomain('foo'); + + //* setUserId + client.setUserId('uid'); + client.setUserId(null); + + //* setGroup + client.setGroup('orgId', '15'); + client.setGroup('sport', ['soccer', 'tennis']); + + //* setOptOut + client.setOptOut(true); + client.setOptOut(false); + + //* regenerateDeviceId + client.regenerateDeviceId(); + + //* setDeviceId + client.setDeviceId('uid'); + + //* setUserProperties + // $ExpectError: setUserProperties requires arguments + r.setUserProperties(); + r.setUserProperties({}); + r.setUserProperties({ foo: 1 }); + r.setUserProperties({ foo: [1] }); + r.setUserProperties({ foo: 'foo' }); + r.setUserProperties({ foo: ['foo'] }); + r.setUserProperties({ foo: [1, 'foo'] }); + + //* clearUserProperties + r.clearUserProperties(); + + //* identify + r.identify(identify); + r.identify(identify, callback); + + //* setVersionName + r.setVersionName('vname'); + + //* logEvent + r.logEvent('event'); + r.logEvent('event', { foo: 1 }); + r.logEvent('event', null, callback); + + //* logEventWithTimestamp + r.logEventWithTimestamp('event'); + r.logEventWithTimestamp('event', { foo: 1 }); + r.logEventWithTimestamp('event', null, Date.now()); + r.logEventWithTimestamp('event', null, null, callback); + + //* logEventWithGroups + r.logEventWithGroups('event'); + r.logEventWithGroups('event', { foo: 1 }); + r.logEventWithGroups('event', null, { orgId: 'some-org-id' }); + r.logEventWithGroups('event', null, null, callback); + + //* logRevenueV2 + r.logRevenueV2(revenue); +} From 34fcf12a993921667b4f4cb1c6fe0ceb7b2eae72 Mon Sep 17 00:00:00 2001 From: Maxim Malov Date: Tue, 13 Mar 2018 23:52:50 +0600 Subject: [PATCH 16/75] Rework react-loadable types to fulfill the current API (#1955) * Rework react-loadable types to fulfill the current API * Rewrite tests using `describe` and `it` blocks * Remove unused type * Provide additional annotations in tests --- .../flow_v0.56.0-/react-loadable_v5.x.x.js | 56 ++++- .../test_react-loadable_v5.x.x.js | 214 +++++++++++++----- 2 files changed, 200 insertions(+), 70 deletions(-) diff --git a/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/react-loadable_v5.x.x.js b/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/react-loadable_v5.x.x.js index 2a8f509bed..89416f76c9 100644 --- a/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/react-loadable_v5.x.x.js +++ b/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/react-loadable_v5.x.x.js @@ -1,13 +1,53 @@ declare module 'react-loadable' { - declare type LoaderResult = T | { 'default': T }; + declare type LoadingProps = { + isLoading: boolean, + pastDelay: boolean, + timedOut: boolean, + error: boolean + }; - declare module.exports:

(opts: { - loader(): Promise>>, - loading: React$ComponentType<*>, + declare type CommonOptions = { + loading: React$ComponentType, delay?: number, timeout?: number, - render?: (r: LoaderResult>, p: P) => React$Node, - webpack?: () => Array, - modules?: Array - }) => React$ComponentType

; + modules?: Array, + webpack?: () => Array + }; + + declare type OptionsWithoutRender = { + ...CommonOptions, + loader(): Promise | { default: React$ComponentType }> + }; + + declare type OptionsWithRender = { + ...CommonOptions, + loader(): Promise, + render(loaded: TModule, props: TProps): React$Node + }; + + declare type Options = OptionsWithoutRender | OptionsWithRender; + + declare type MapOptions = { + ...CommonOptions, + loader: { + [key: $Keys]: () => Promise<*> + }, + render(loaded: TModules, props: TProps): React$Node + }; + + declare class LoadableComponent extends React$Component { + static preload(): Promise + } + + declare type CaptureProps = { + report(moduleName: string): void + }; + + declare module.exports: { + (opts: Options): Class>, + Map(opts: MapOptions): Class>, + Capture: React$ComponentType, + preloadAll(): Promise, + preloadReady(): Promise, + }; } diff --git a/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/test_react-loadable_v5.x.x.js b/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/test_react-loadable_v5.x.x.js index 59313728fb..a1e047a97f 100644 --- a/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/test_react-loadable_v5.x.x.js +++ b/definitions/npm/react-loadable_v5.x.x/flow_v0.56.0-/test_react-loadable_v5.x.x.js @@ -2,86 +2,176 @@ import React from 'react'; import Loadable from 'react-loadable'; +import { describe, it } from 'flow-typed-test'; -// $ExpectError options object is required -Loadable(); +type Props = { a: string }; +class Component extends React.Component {} -// $ExpectError loader option is required -Loadable({ - loading: () => null -}); +describe('options', () => { + it('should fail when props is not provided', () => { + // $ExpectError + Loadable(); + }); -// $ExpectError loader option should return a promise that resolves to a react component or a module object with default export which is a react component -Loadable({ - loader: () => Promise.resolve(1), - loading: () => null -}); + it('should fail when loader is missing', () => { + // $ExpectError + Loadable({ + loading: () => null + }); + }); -type Props = { a: string }; + it('should fail when loader option does not return a promise that resolves to a react component or a module object with default export which is a react component', () => { + // $ExpectError + Loadable({ + loader: () => Promise.resolve(1), + loading: () => null + }); + }); -class Component extends React.Component {} + it('delay property should be a number', () => { + // $ExpectError + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + delay: '' + }); + + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + delay: 1 + }); + }); -// $ExpectError delay option should be a number -Loadable({ - loader: () => Promise.resolve(Component), - loading: () => null, - delay: '' -}); + it('timeout property should be a number', () => { + // $ExpectError + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + timeout: '' + }); + + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + timeout: 1 + }); + }); -// $ExpectError timeout option should be a number -Loadable({ - loader: () => Promise.resolve(Component), - loading: () => null, - timeout: '' -}); + it('webpack option should be a function', () => { + // $ExpectError + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + webpack: [] + }); + + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + webpack: () => [1] + }); + }); -// $ExpectError webpack option should be a function -Loadable({ - loader: () => Promise.resolve(Component), - loading: () => null, - webpack: [] -}); + it('modules options should be an array of strings', () => { + // $ExpectError modules option should be an array of module names + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + modules: [1] + }); + + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + modules: ['f', 'o', 'o'] + }); + }); -// $ExpectError modules option should be an array of module names -Loadable({ - loader: () => Promise.resolve(Component), - loading: () => null, - modules: [1] + it('render option should take a resolved module and related component props', () => { + // $ExpectError render option should take a resolved module and related component props + Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null, + render: (a: string, b: string) => null + }); + }); }); -// $ExpectError render option should take a resolved module and related component props -Loadable({ - loader: () => Promise.resolve(Component), - loading: () => null, - render: (a: string, b: string) => null -}); +describe('props refinements', () => { + class SyncComponent extends React.Component<{ a: string, b: number }> {} + + it('should refine props type from render function', () => { + const LoadableComponent = Loadable({ + loader: (): Promise => Promise.resolve(1), + loading: () => null, + render: (b: number, props: Props) => + }); + + const foo = ; + // $ExpectError + const bar = ; + }); + + it('should refine props type from loader option', () => { + const Loaded1 = Loadable({ + loader: () => Promise.resolve(Component), + loading: () => null + }); + + // $ExpectError + const noWay = ; + ; + + const Loaded2 = Loadable({ + loader: () => Promise.resolve({ default: Component }), + loading: () => null + }); + + // $ExpectError + const noWay = ; -Loadable({ - loader: () => Promise.resolve(Component), - loading: () => null, - render: (C: React$ComponentType | { default: React$ComponentType }, props: Props) => null + + }); }); -{ - const Loaded = Loadable({ - loader: () => Promise.resolve(Component), - loading: () => null +describe('result component', () => { + it('should be a react component', () => { + const LoadableComponent: React$ComponentType = Loadable({ + loader: () => Promise.resolve({ default: Component }), + loading: () => null + }); }); - // $ExpectError "a" property should be a string (inherited from Component) - const noWay = ; + it('should have preload() static method', () => { + const LoadableComponent = Loadable({ + loader: () => Promise.resolve({ default: Component }), + loading: () => null + }); + + LoadableComponent.preload(); + }); +}); - -} +it('Loadable.Map() should work', () => { + class Component extends React.Component<{ a: string, b: number }> {} -{ - const Loaded = Loadable({ - loader: () => Promise.resolve({ default: Component }), - loading: () => null + const LoadableMap = Loadable.Map({ + loading: () => null, + loader: { + Cmp: () => Promise.resolve({ foo: Component }), + b: () => Promise.resolve(1) + }, + render: (loaded: { Cmp: { foo: React$ComponentType<{ a: string, b: number }> }, b: number }, props: { a: string }) => }); - // $ExpectError "a" property should be a string (inherited from Component) - const noWay = ; + +}); + +it('Loadable.preloadAll()', () => { + Loadable.preloadAll(); +}); - -} +it('Loadable.preloadReady()', () => { + Loadable.preloadReady(); +}); From 9a51140319d2c1b8e3c0126fe66167b320aa2e1a Mon Sep 17 00:00:00 2001 From: Craig Bruce Date: Wed, 14 Mar 2018 05:26:34 +1100 Subject: [PATCH 17/75] Enhancement: Add missing enums and minor cleanup. (#1950) * Enhancement: Add missing enums and minor cleanup. * Properly export enum types and fix some imports/errors * Remove '| null' constraint --- .../chromecast-caf-receiver_v3.x.x.js | 689 +++++++++++++++--- .../test_chromecast-caf-receiver_v3.x.x.js | 4 +- 2 files changed, 590 insertions(+), 103 deletions(-) diff --git a/definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js b/definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js index 1563325725..45bf42c9c8 100644 --- a/definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js +++ b/definitions/browser/chromecast-caf-receiver_v3.x.x/flow_v0.25.x-/chromecast-caf-receiver_v3.x.x.js @@ -1,4 +1,464 @@ // @flow +import { ApplicationData } from 'cast.framework.system'; + +export const DisconnectReasonEnum = { + REQUESTED_BY_SENDER: 'REQUESTED_BY_SENDER', + ERROR: 'ERROR', + UNKNOWN: 'UNKNOWN', +}; +export const LoggerLevelEnum = { + DEBUG: 'DEBUG', + VERBOSE: 'VERBOSE', + INFO: 'INFO', + WARNING: 'WARNING', + ERROR: 'ERROR', + NONE: 'NONE', +}; + +export const SystemStateEnum = { + NOT_STARTED: 'NOT_STARTED', + STARTING_IN_BACKGROUND: 'STARTING_IN_BACKGROUND', + STARTING: 'STARTING', + READY: 'READY', + STOPPING_IN_BACKGROUND: 'STOPPING_IN_BACKGROUND', + STOPPING: 'STOPPING', +}; + +export const StandbyStateEnum = { + STANDBY: 'STANDBY', + NOT_STANDBY: 'NOT_STANDBY', + UNKNOWN: 'UNKNOWN', +}; + +export const ContentProtectionEnum = { + NONE: 'NONE', + CLEARKEY: 'CLEARKEY', + PLAYREADY: 'PLAYREADY', + WIDEVINE: 'WIDEVINEE', +}; + +export const PlayerStateEnum = { + IDLE: 'IDLE', + PLAYING: 'PLAYING', + PAUSED: 'PAUSED', + BUFFERING: 'BUFFERING', +}; + +export const QueueChangeTypeEnum = { + INSERT: 'INSERT', + REMOVE: 'REMOVE', + ITEMS_CHANGE: 'ITEMS_CHANGE', + UPDATE: 'UPDATE', + NO_CHANGE: 'NO_CHANGE', +}; + +export const QueueTypeEnum = { + ALBUM: 'ALBUM', + PLAYLIST: 'PLAYLIST', + AUDIOBOOK: 'AUDIOBOOK', + RADIO_STATION: 'RADIO_STATION', + PODCAST_SERIES: 'PODCAST_SERIES', + TV_SERIES: 'TV_SERIES', + VIDEO_PLAYLIST: 'VIDEO_PLAYLIST', + LIVE_TV: 'LIVE_TV', + MOVIE: 'MOVIE', +}; + +export const MetadataTypeEnum = { + GENERIC: 'GENERIC', + MOVIE: 'MOVIE', + TV_SHOW: 'TV_SHOW', + MUSIC_TRACK: 'MUSIC_TRACK', + PHOTO: 'PHOTO', +}; + +export const MessageTypeEnum = { + MEDIA_STATUS: 'MEDIA_STATUS', + CLOUD_STATUS: 'CLOUD_STATUS', + QUEUE_CHANGE: 'QUEUE_CHANGE', + QUEUE_ITEMS: 'QUEUE_ITEMS', + QUEUE_ITEM_IDS: 'QUEUE_ITEM_IDS', + GET_STATUS: 'GET_STATUS', + LOAD: 'LOAD', + PAUSE: 'PAUSE', + STOP: 'STOP', + PLAY: 'PLAY', + SKIP_AD: 'SKIP_AD', + PLAY_AGAIN: 'PLAY_AGAIN', + SEEK: 'SEEK', + SET_PLAYBACK_RATE: 'SET_PLAYBACK_RATE', + SET_VOLUME: 'SET_VOLUME', + EDIT_TRACKS_INFO: 'EDIT_TRACKS_INFO', + EDIT_AUDIO_TRACKS: 'EDIT_AUDIO_TRACKS', + PRECACHE: 'PRECACHE', + PRELOAD: 'PRELOAD', + QUEUE_LOAD: 'QUEUE_LOAD', + QUEUE_INSERT: 'QUEUE_INSERT', + QUEUE_UPDATE: 'QUEUE_UPDATE', + QUEUE_REMOVE: 'QUEUE_REMOVE', + QUEUE_REORDER: 'QUEUE_REORDER', + QUEUE_NEXT: 'QUEUE_NEXT', + QUEUE_PREV: 'QUEUE_PREV', + QUEUE_GET_ITEM_RANGE: 'QUEUE_GET_ITEM_RANGE', + QUEUE_GET_ITEMS: 'QUEUE_GET_ITEMS', + QUEUE_GET_ITEM_IDS: 'QUEUE_GET_ITEM_IDS', + QUEUE_SHUFFLE: 'QUEUE_SHUFFLE', + SET_CREDENTIALS: 'SET_CREDENTIALS', + LOAD_BY_ENTITY: 'LOAD_BY_ENTITY', + USER_ACTION: 'USER_ACTION', + DISPLAY_STATUS: 'DISPLAY_STATUS', + FOCUS_STATE: 'FOCUS_STATE', + CUSTOM_COMMAND: 'CUSTOM_COMMAND', +}; + +export const RepeatModeEnum = { + REPEAT_OFF: 'REPEAT_OFF', + REPEAT_ALL: 'REPEAT_ALL', + REPEAT_SINGLE: 'REPEAT_SINGLE', + REPEAT_ALL_AND_SHUFFLE: 'REPEAT_ALL_AND_SHUFFLE', +}; + +export const IdleReasonEnum = { + CANCELLED: 'CANCELLED', + INTERRUPTED: 'INTERRUPTED', + FINISHED: 'FINISHED', + ERROR: 'ERROR', +}; + +export const HlsSegmentFormatEnum = { + AAC: 'AAC', + AC3: 'AC3', + MP3: 'MP3', + TS: 'TS', + TS_AAC: 'TS_AAC', +}; + +export const HdrTypeEnum = { + SDR: 'SDR', + HDR: 'HDR', + DV: 'DV', +}; + +export const PlayStringIdEnum = { + FREE_TRIAL_ABOUT_TO_EXPIRE: 'FREE_TRIAL_ABOUT_TO_EXPIRE', + SUBSCRIPTION_ABOUT_TO_EXPIRE: 'SUBSCRIPTION_ABOUT_TO_EXPIRE', + STREAM_HIJACKED: 'STREAM_HIJACKED', +}; + +export const GetStatusOptionsEnum = { + NO_METADATA: 'NO_METADATA', + NO_QUEUE_ITEMS: 'NO_QUEUE_ITEMS', +}; + +export const FocusStateEnum = { + IN_FOCUS: 'IN_FOCUS', + NOT_IN_FOCUS: 'NOT_IN_FOCUS', +}; + +export const ExtendedPlayerStateEnum = { + LOADING: 'LOADING', +}; + +export const ErrorTypeEnum = { + INVALID_PLAYER_STATE: 'INVALID_PLAYER_STATE', + LOAD_FAILED: 'LOAD_FAILED', + LOAD_CANCELLED: 'LOAD_CANCELLED', + INVALID_REQUEST: 'INVALID_REQUEST', + ERROR: 'ERROR', +}; + +export const ErrorReasonEnum = { + INVALID_COMMAND: 'INVALID_COMMAND', + INVALID_PARAMS: 'INVALID_PARAMS', + INVALID_MEDIA_SESSION_ID: 'INVALID_MEDIA_SESSION_ID', + SKIP_LIMIT_REACHED: 'SKIP_LIMIT_REACHED', + NOT_SUPPORTED: 'NOT_SUPPORTED', + LANGUAGE_NOT_SUPPORTED: 'LANGUAGE_NOT_SUPPORTED', + END_OF_QUEUE: 'END_OF_QUEUE', + APP_ERROR: 'APP_ERROR', + AUTHENTICATION_EXPIRED: 'AUTHENTICATION_EXPIRED', + PREMIUM_ACCOUNT_REQUIRED: 'PREMIUM_ACCOUNT_REQUIRED', + CONCURRENT_STREAM_LIMIT: 'CONCURRENT_STREAM_LIMIT', + PARENTAL_CONTROL_RESTRICTED: 'PARENTAL_CONTROL_RESTRICTED', + NOT_AVAILABLE_IN_REGION: 'NOT_AVAILABLE_IN_REGION', + CONTENT_ALREADY_PLAYING: 'CONTENT_ALREADY_PLAYING', + INVALID_REQUEST: 'INVALID_REQUEST', + GENERIC_LOAD_ERROR: 'GENERIC_LOAD_ERROR', +}; + +export const CommandEnum = { + PAUSE: 'PAUSE', + SEEK: 'SEEK', + STREAM_VOLUME: 'STREAM_VOLUME', + STREAM_MUTE: 'STREAM_MUTE', + ALL_BASIC_MEDIA: 'ALL_BASIC_MEDIA', + QUEUE_NEXT: 'QUEUE_NEXT', + QUEUE_PREV: 'QUEUE_PREV', + QUEUE_SHUFFLE: 'QUEUE_SHUFFLE', + SKIP_AD: 'SKIP_AD', +}; + +export const SeekResumeStateEnum = { PLAYBACK_START: 'PLAYBACK_START', + PLAYBACK_PAUSE: 'PLAYBACK_PAUSE', +}; + +export const StreamingProtocolTypeEnum = { + UNKNOWN: 'UNKNOWN', + MPEG_DASH: 'MPEG_DASH', + HLS: 'HLS', + SMOOTH_STREAMING: 'SMOOTH_STREAMING', +}; + +export const StreamTypeEnum = { + BUFFERED: 'BUFFERED', + LIVE: 'LIVE', + NONE: 'NONE', +}; + +export const TextTrackEdgeTypeEnum = { + NONE: 'NONE', + OUTLINE: 'OUTLINE', + DROP_SHADOW: 'DROP_SHADOW', + RAISED: 'RAISED', + DEPRESSED: 'DEPRESSED', +}; + +export const TextTrackFontGenericFamilyEnum = { + SANS_SERIF: 'SANS_SERIF', + MONOSPACED_SANS_SERIF: 'MONOSPACED_SANS_SERIF', + SERIF: 'SERIF', + MONOSPACED_SERIF: 'MONOSPACED_SERIF', + CASUAL: 'CASUAL', + CURSIVE: 'CURSIVE', + SMALL_CAPITALS: 'SMALL_CAPITALS:', +}; + +export const TextTrackFontStyleEnum = { + NORMAL: 'NORMAL', + BOLD: 'BOLD', + BOLD_ITALIC: 'BOLD_ITALIC', + ITALIC: 'ITALIC', +}; + +export const TextTrackTypeEnum = { + SUBTITLES: 'SUBTITLES', + CAPTIONS: 'CAPTIONS', + DESCRIPTIONS: 'DESCRIPTIONS', + CHAPTERS: 'CHAPTERS', + METADATA: 'METADATA', +}; + +export const TextTrackWindowTypeEnum = { + NONE: 'NONE', + NORMAL: 'NORMAL', + ROUNDED_CORNERS: 'ROUNDED_CORNERS', +}; + +export const TrackTypeEnum = { + TEXT: 'TEXT', + AUDIO: 'AUDIO', + VIDEO: 'VIDEO', +}; + +export const UserActionContextEnum = { + UNKNOWN_CONTEXT: 'UNKNOWN_CONTEXT', + ALBUM: 'ALBUM', + ARTIST: 'ARTIST', + PLAYLIST: 'PLAYLIST', + EPISODE: 'EPISODE', + SERIES: 'SERIES', + MOVIE: 'MOVIE', + CHANNEL: 'CHANNEL', + TEAM: 'TEAM', + PLAYER: 'PLAYER', + COACH: 'COACH', +}; + +export const UserActionEnum = { + LIKE: 'LIKE', + DISLIKE: 'DISLIKE', + FOLLOW: 'FOLLOW', + UNFOLLOW: 'UNFOLLOW', + FLAG: 'FLAG', + SKIP_AD: 'SKIP_AD', +}; + +export const EndedReasonEnum = { + END_OF_STREAM: 'END_OF_STREAM', + ERROR: 'ERROR', + STOPPED: 'STOPPED', + INTERRUPTED: 'INTERRUPTED', + SKIPPED: 'SKIPPED', + BREAK_SWITCH: 'BREAK_SWITCH', +}; + +export const DetailedErrorCodeEnum = { + MEDIA_UNKNOWN: 'MEDIA_UNKNOWN', + MEDIA_ABORTED: 'MEDIA_ABORTED', + MEDIA_DECODE: 'MEDIA_DECODE', + MEDIA_NETWORK: 'MEDIA_NETWORK', + MEDIA_SRC_NOT_SUPPORTED: 'MEDIA_SRC_NOT_SUPPORTED', + SOURCE_BUFFER_FAILURE: 'SOURCE_BUFFER_FAILURE', + MEDIAKEYS_UNKNOWN: 'MEDIAKEYS_UNKNOWN', + MEDIAKEYS_NETWORK: 'MEDIAKEYS_NETWORK', + MEDIAKEYS_UNSUPPORTED: 'MEDIAKEYS_UNSUPPORTED', + MEDIAKEYS_WEBCRYPTO: 'MEDIAKEYS_WEBCRYPTO', + NETWORK_UNKNOWN: 'NETWORK_UNKNOWN', + SEGMENT_NETWORK: 'SEGMENT_NETWORK', + HLS_NETWORK_MASTER_PLAYLIST: 'HLS_NETWORK_MASTER_PLAYLIST', + HLS_NETWORK_PLAYLIST: 'HLS_NETWORK_PLAYLIST', + HLS_NETWORK_NO_KEY_RESPONSE: 'HLS_NETWORK_NO_KEY_RESPONSE', + HLS_NETWORK_KEY_LOAD: 'HLS_NETWORK_KEY_LOAD', + HLS_NETWORK_INVALID_SEGMENT: 'HLS_NETWORK_INVALID_SEGMENT', + HLS_SEGMENT_PARSING: 'HLS_SEGMENT_PARSING', + DASH_NETWORK: 'DASH_NETWORK', + DASH_NO_INIT: 'DASH_NO_INIT', + SMOOTH_NETWORK: 'SMOOTH_NETWORK', + SMOOTH_NO_MEDIA_DATA: 'SMOOTH_NO_MEDIA_DATA', + MANIFEST_UNKNOWN: 'MANIFEST_UNKNOWN', + HLS_MANIFEST_MASTER: 'HLS_MANIFEST_MASTER', + HLS_MANIFEST_PLAYLIST: 'HLS_MANIFEST_PLAYLIST', + DASH_MANIFEST_UNKNOWN: 'DASH_MANIFEST_UNKNOWN', + DASH_MANIFEST_NO_PERIODS: 'DASH_MANIFEST_NO_PERIODS', + DASH_MANIFEST_NO_MIMETYPE: 'DASH_MANIFEST_NO_MIMETYPE', + DASH_INVALID_SEGMENT_INFO: 'DASH_INVALID_SEGMENT_INFO', + SMOOTH_MANIFEST: 'SMOOTH_MANIFEST', + SEGMENT_UNKNOWN: 'SEGMENT_UNKNOWN', + TEXT_UNKNOWN: 'TEXT_UNKNOWN', + APP: 'APP', + BREAK_CLIP_LOADING_ERROR: 'BREAK_CLIP_LOADING_ERROR', + BREAK_SEEK_INTERCEPTOR_ERROR: 'BREAK_SEEK_INTERCEPTOR_ERROR', + IMAGE_ERROR: 'IMAGE_ERROR', + LOAD_INTERRUPTED: 'LOAD_INTERRUPTED', + GENERIC: 'GENERIC', +}; + +export const ContentTypeEnum = { + VIDEO: 'VIDEO', + AUDIO: 'AUDIO', + IMAGE: 'IMAGE', +}; + +export const StateEnum = { + LAUNCHING: 'LAUNCHING', + IDLE: 'IDLE', + LOADING: 'LOADING', + BUFFERING: 'BUFFERING', + PAUSED: 'PAUSED', + PLAYING: 'PLAYING', +}; + +export const PlayerDataEventTypeEnum = { + ANY_CHANGE: 'ANY_CHANGE', + STATE_CHANGED: 'STATE_CHANGED', + IS_SEEKING_CHANGED: 'IS_SEEKING_CHANGED', + DURATION_CHANGED: 'DURATION_CHANGED', + CURRENT_TIME_CHANGED: 'CURRENT_TIME_CHANGED', + METADATA_CHANGED: 'METADATA_CHANGED', + TITLE_CHANGED: 'TITLE_CHANGED', + SUBTITLE_CHANGED: 'SUBTITLE_CHANGED', + THUMBNAIL_URL_CHANGED: 'THUMBNAIL_URL_CHANGED:', + NEXT_TITLE_CHANGED: 'NEXT_TITLE_CHANGED', + NEXT_SUBTITLE_CHANGED: 'NEXT_SUBTITLE_CHANGED', + NEXT_THUMBNAIL_URL_CHANGED: 'NEXT_THUMBNAIL_URL_CHANGED', + PRELOADING_NEXT_CHANGED: 'PRELOADING_NEXT_CHANGED', + CONTENT_TYPE_CHANGED: 'CONTENT_TYPE_CHANGED', + IS_LIVE_CHANGED: 'IS_LIVE_CHANGED', + BREAK_PERCENTAGE_POSITIONS_CHANGED: 'BREAK_PERCENTAGE_POSITIONS_CHANGED', + IS_PLAYING_BREAK_CHANGED: 'IS_PLAYING_BREAK_CHANGED', + IS_BREAK_SKIPPABLE_CHANGED: 'IS_BREAK_SKIPPABLE_CHANGED', + WHEN_SKIPPABLE_CHANGED: 'WHEN_SKIPPABLE_CHANGED', + NUMBER_BREAK_CLIPS_CHANGED: 'NUMBER_BREAK_CLIPS_CHANGED', + CURRENT_BREAK_CLIP_NUMBER_CHANGED: 'CURRENT_BREAK_CLIP_NUMBER_CHANGED', + DISPLAY_STATUS_CHANGED: 'DISPLAY_STATUS_CHANGED', +}; + +export const EventTypeEnum = { + ALL: 'ALL', + ABORT: 'ABORT', + CAN_PLAY: 'CAN_PLAY', + CAN_PLAY_THROUGH: 'CAN_PLAY_THROUGH', + DURATION_CHANGE: 'DURATION_CHANGE', + EMPTIED: 'EMPTIED', + ENDED: 'ENDED', + LOADED_DATA: 'LOADED_DATA', + LOADED_METADATA: 'LOADED_METADATA', + LOAD_START: 'LOAD_START', + PAUSE: 'PAUSE', + PLAY: 'PLAY', + PLAYING: 'PLAYING', + PROGRESS: 'PROGRESS', + RATE_CHANGE: 'RATE_CHANGE', + SEEKED: 'SEEKED', + SEEKING: 'SEEKING', + STALLED: 'STALLED', + TIME_UPDATE: 'TIME_UPDATE', + SUSPEND: 'SUSPEND', + WAITING: 'WAITING', + BITRATE_CHANGED: 'BITRATE_CHANGED', + BREAK_STARTED: 'BREAK_STARTED', + BREAK_ENDED: 'BREAK_ENDED', + BREAK_CLIP_LOADING: 'BREAK_CLIP_LOADING', + BREAK_CLIP_STARTED: 'BREAK_CLIP_STARTED', + BREAK_CLIP_ENDED: 'BREAK_CLIP_ENDED', + BUFFERING: 'BUFFERING', + CACHE_LOADED: 'CACHE_LOADED', + CACHE_HIT: 'CACHE_HIT', + CACHE_INSERTED: 'CACHE_INSERTED', + CLIP_STARTED: 'CLIP_STARTED', + CLIP_ENDED: 'CLIP_ENDED', + EMSG: 'EMSG', + ERROR: 'ERROR', + ID3: 'ID3', + MEDIA_STATUS: 'MEDIA_STATUS', + MEDIA_FINISHED: 'MEDIA_FINISHED', + PLAYER_PRELOADING: 'PLAYER_PRELOADING', + PLAYER_PRELOADING_CANCELLED: 'PLAYER_PRELOADING_CANCELLED', + PLAYER_LOAD_COMPLETE: 'PLAYER_LOAD_COMPLETE', + PLAYER_LOADING: 'PLAYER_LOADING', + SEGMENT_DOWNLOADED: 'SEGMENT_DOWNLOADED', + REQUEST_SEEK: 'REQUEST_SEEK', + REQUEST_LOAD: 'REQUEST_LOAD', + REQUEST_STOP: 'REQUEST_STOP', + REQUEST_PAUSE: 'REQUEST_PAUSE', + REQUEST_PLAY: 'REQUEST_PLAY', + REQUEST_PLAY_AGAIN: 'REQUEST_PLAY_AGAIN', + REQUEST_PLAYBACK_RATE_CHANGE: 'REQUEST_PLAYBACK_RATE_CHANGE', + REQUEST_SKIP_AD: 'REQUEST_SKIP_AD', + REQUEST_VOLUME_CHANGE: 'REQUEST_VOLUME_CHANGE', + REQUEST_EDIT_TRACKS_INFO: 'REQUEST_EDIT_TRACKS_INFO', + REQUEST_EDIT_AUDIO_TRACKS: 'REQUEST_EDIT_AUDIO_TRACKS', + REQUEST_SET_CREDENTIALS: 'REQUEST_SET_CREDENTIALS', + REQUEST_LOAD_BY_ENTITY: 'REQUEST_LOAD_BY_ENTITY', + REQUEST_USER_ACTION: 'REQUEST_USER_ACTION', + REQUEST_DISPLAY_STATUS: 'REQUEST_DISPLAY_STATUS', + REQUEST_CUSTOM_COMMAND: 'REQUEST_CUSTOM_COMMAND', + REQUEST_FOCUS_STATE: 'REQUEST_FOCUS_STATE', + REQUEST_QUEUE_LOAD: 'REQUEST_QUEUE_LOAD', + REQUEST_QUEUE_INSERT: 'REQUEST_QUEUE_INSERT', + REQUEST_QUEUE_UPDATE: 'REQUEST_QUEUE_UPDATE', + REQUEST_QUEUE_REMOVE: 'REQUEST_QUEUE_REMOVE', + REQUEST_QUEUE_REORDER: 'REQUEST_QUEUE_REORDER', + REQUEST_QUEUE_GET_ITEM_RANGE: 'REQUEST_QUEUE_GET_ITEM_RANGE', + REQUEST_QUEUE_GET_ITEMS: 'REQUEST_QUEUE_GET_ITEMS', + REQUEST_QUEUE_GET_ITEM_IDS: 'REQUEST_QUEUE_GET_ITEM_IDS', + BREAK_CLIP_ENDED: 'BREAK_CLIP_ENDED', + BREAK_CLIP_STARTED: 'BREAK_CLIP_STARTED', + BUFFERING: 'BUFFERING', + ERROR: 'ERROR', + MEDIA_FINISHED: 'MEDIA_FINISHED', + MEDIA_STATUS: 'MEDIA_STATUS', + PAUSE: 'PAUSE', + PLAYER_LOADING: 'PLAYER_LOADING', + PLAYER_LOAD_COMPLETE: 'PLAYER_LOAD_COMPLETE', + PLAYER_PRELOADING: 'PLAYER_PRELOADING', + PLAYER_PRELOADING_CANCELLED: 'PLAYER_PRELOADING_CANCELLED', + PLAYING: 'PLAYING', + REQUEST_PRECACHE: 'REQUEST_PRECACHE', + RATE_CHANGE: 'RATE_CHANGE', + SEEKED: 'SEEKED', + SEEKING: 'SEEKING', +}; declare module 'cast' { import type { PlayerDataChangedEvent } from 'cast.framework.ui'; @@ -19,16 +479,34 @@ declare module 'cast.framework' { QueueData, LoadRequestData, Break, - } from 'cast.framework.messages'; - - import type { BreakManager } from 'cast.framework.breaks'; - import type { LiveSeekableRange, PlayerState, MediaInformation, - PlayerStringId, + PlayStringId, + ErrorData, + ErrorType, + IdleReason, + MessageType, + ErrorReason, + RequestData, } from 'cast.framework.messages'; + import type { BreakManager } from 'cast.framework.breaks'; + + import type { EventType } from 'cast.framework.events'; + + import type { RequestHandler, BinaryHandler } from 'cast'; + + import type { + ApplicationData, + Sender, + StandbyState, + SystemState, + DisconnectReason, + } from 'cast.framework.system'; + + declare export type ContentProtection = $Keys; + declare export type LoggerLevel = $Keys; /** * Manages text tracks. */ @@ -383,7 +861,7 @@ declare module 'cast.framework' { * Sets a handler to return the media url for a load request. This handler can be used to avoid having the media content url published as part of the media status. By default the media contentId is used as the content url. */ setMediaUrlResolver( - resolver: (loadRequestData: LoadRequestData | null) => void, + resolver: (loadRequestData: LoadRequestData ) => void, ): void; /** @@ -391,7 +869,7 @@ declare module 'cast.framework' { */ setMessageInterceptor( type: MessageType, - interceptor: (requestData: RequestData | null) => void, + interceptor: (requestData: RequestData ) => void, ): void; /** @@ -501,7 +979,7 @@ declare module 'cast.framework' { /** * The content of the request. Can be used to modify license request body. */ - content: Uint8Array | null; + content: Uint8Array ; /** * An object containing properties that you would like to send in the header. @@ -511,7 +989,7 @@ declare module 'cast.framework' { /** * The URL requested. */ - url: string | null; + url: string ; /** * Indicates whether CORS Access-Control requests should be made using credentials such as cookies or authorization headers. @@ -740,9 +1218,9 @@ declare module 'cast.framework' { /** Manages audio tracks. */ declare export class AudioTracksManager { constructor(params: mixed): AudioTracksManager; - getActiveId(): number | null; - getActiveTrack(): Track | null; - getTrackById(id: number): Track | null; + getActiveId(): number ; + getActiveTrack(): Track ; + getTrackById(id: number): Track ; getTracks(): Array; getTracksByLanguage(language: string): Array; setActiveById(id: number): void; @@ -750,6 +1228,14 @@ declare module 'cast.framework' { } } declare module 'cast.framework.system' { + import type { EventType } from 'cast.framework.events'; + + declare export type SystemState = $Keys; + + declare export type DisconnectReason = $Keys; + + declare export type StandbyState = $Keys; + /** * Event dispatched by @see{@link CastReceiverManager} when the visibility of the application changes (HDMI input change, TV is turned off). */ @@ -900,6 +1386,16 @@ declare module 'cast.framework.system' { } } declare module 'cast.framework.ui' { + import type { MediaMetadata } from 'cast.framework.messages'; + + declare export type ContentType = $Keys; + + declare export type State = $Keys; + + declare export type PlayerDataEventType = $Keys< + typeof PlayerDataEventTypeEnum, + >; + /** * Player data changed event. Provides the changed field (type), and new value. */ @@ -1047,6 +1543,8 @@ declare module 'cast.framework.ui' { } } declare module 'cast.framework.breaks' { + import type { Break, BreakClip, RequestData } from 'cast.framework.messages'; + declare export class BreakSeekData { constructor( seekFrom: number, @@ -1086,13 +1584,13 @@ declare module 'cast.framework.breaks' { * Get current media break by id. * @param {*} id */ - getBreakById(id: string): Break | null; + getBreakById(id: string): Break ; /** * Get current media break clip by id * @param {*} id */ - getBreakClipById(id: string): BreakClip | null; + getBreakClipById(id: string): BreakClip ; /** Get current media break clips. */ getBreakClips(): Array; @@ -1144,8 +1642,18 @@ declare module 'cast.framework.breaks' { ): void; } } + declare module 'cast.framework.events' { - import type { EventType } from 'cast.framework.events'; + import type { + RequestData, + MediaInformation, + Track, + MediaStatus, + } from 'cast.framework.messages'; + + declare export type EventType = $Keys; + declare export type DetailedErrorCode = $Keys; + declare export type EndedReason = $Keys; /** * Event data for @see{@link EventType.SEGMENT_DOWNLOADED} event. */ @@ -1437,91 +1945,68 @@ declare module 'cast.framework.events' { } } -declare module 'cast.framework.events.category' { - declare export type EventType = { - REQUEST_SEEK: 'REQUEST_SEEK', - REQUEST_LOAD: 'REQUEST_LOAD', - REQUEST_STOP: 'REQUEST_STOP', - REQUEST_PAUSE: 'REQUEST_PAUSE', - REQUEST_PLAY: 'REQUEST_PLAY', - REQUEST_PLAY_AGAIN: 'REQUEST_PLAY_AGAIN', - REQUEST_PLAYBACK_RATE_CHANGE: 'REQUEST_PLAYBACK_RATE_CHANGE', - REQUEST_SKIP_AD: 'REQUEST_SKIP_AD', - REQUEST_VOLUME_CHANGE: 'REQUEST_VOLUME_CHANGE', - REQUEST_EDIT_TRACKS_INFO: 'REQUEST_EDIT_TRACKS_INFO', - REQUEST_EDIT_AUDIO_TRACKS: 'REQUEST_EDIT_AUDIO_TRACKS', - REQUEST_SET_CREDENTIALS: 'REQUEST_SET_CREDENTIALS', - REQUEST_LOAD_BY_ENTITY: 'REQUEST_LOAD_BY_ENTITY', - REQUEST_USER_ACTION: 'REQUEST_USER_ACTION', - REQUEST_DISPLAY_STATUS: 'REQUEST_DISPLAY_STATUS', - REQUEST_CUSTOM_COMMAND: 'REQUEST_CUSTOM_COMMAND', - REQUEST_FOCUS_STATE: 'REQUEST_FOCUS_STATE', - REQUEST_QUEUE_LOAD: 'REQUEST_QUEUE_LOAD', - REQUEST_QUEUE_INSERT: 'REQUEST_QUEUE_INSERT', - REQUEST_QUEUE_UPDATE: 'REQUEST_QUEUE_UPDATE', - REQUEST_QUEUE_REMOVE: 'REQUEST_QUEUE_REMOVE', - REQUEST_QUEUE_REORDER: 'REQUEST_QUEUE_REORDER', - REQUEST_QUEUE_GET_ITEM_RANGE: 'REQUEST_QUEUE_GET_ITEM_RANGE', - REQUEST_QUEUE_GET_ITEMS: 'REQUEST_QUEUE_GET_ITEMS', - REQUEST_QUEUE_GET_ITEM_IDS: 'REQUEST_QUEUE_GET_ITEM_IDS', - BREAK_CLIP_ENDED: 'BREAK_CLIP_ENDED', - BREAK_CLIP_STARTED: 'BREAK_CLIP_STARTED', - BUFFERING: 'BUFFERING', - ERROR: 'ERROR', - MEDIA_FINISHED: 'MEDIA_FINISHED', - MEDIA_STATUS: 'MEDIA_STATUS', - PAUSE: 'PAUSE', - PLAYER_LOADING: 'PLAYER_LOADING', - PLAYER_LOAD_COMPLETE: 'PLAYER_LOAD_COMPLETE', - PLAYER_PRELOADING: 'PLAYER_PRELOADING', - PLAYER_PRELOADING_CANCELLED: 'PLAYER_PRELOADING_CANCELLED', - PLAYING: 'PLAYING', - REQUEST_PRECACHE: 'REQUEST_PRECACHE', - RATE_CHANGE: 'RATE_CHANGE', - SEEKED: 'SEEKED', - SEEKING: 'SEEKING', - }; -} - declare module 'cast.framework.messages' { - declare export type RepeatMode = { - REPEAT_OFF: 'REPEAT_OFF', - REPEAT_ALL: 'REPEAT_ALL', - REPEAT_SINGLE: 'REPEAT_SINGLE', - REPEAT_ALL_AND_SHUFFLE: 'REPEAT_ALL_AND_SHUFFLE', - }; - - declare export type QueueType = { - ALBUM: 'ALBUM', - PLAYLIST: 'PLAYLIST', - AUDIOBOOK: 'AUDIOBOOK', - RADIO_STATION: 'RADIO_STATION', - PODCAST_SERIES: 'PODCAST_SERIES', - TV_SERIES: 'TV_SERIES', - VIDEO_PLAYLIST: 'VIDEO_PLAYLIST', - LIVE_TV: 'LIVE_TV', - MOVIE: 'MOVIE', - }; - declare export type QueueChangeType = { - INSERT: 'INSERT', - REMOVE: 'REMOVE', - ITEMS_CHANGE: 'ITEMS_CHANGE', - UPDATE: 'UPDATE', - NO_CHANGE: 'NO_CHANGE', - }; - - declare export type PlayerState = { - IDLE: 'IDLE', - PLAYING: 'PLAYING', - PAUSED: 'PAUSED', - BUFFERING: 'BUFFERING', - }; - - declare export type PlayerStringId = { - FREE_TRIAL_ABOUT_TO_EXPIRE: '', - SUBSCRIPTION_ABOUT_TO_EXPIRE: '', - STREAM_HIJACKED: '', - }; + import type { DetailedErrorCode } from 'cast.framework.events'; + + declare export type UserAction = $Keys; + + declare export type UserActionContext = $Keys; + + declare export type TrackType = $Keys; + + declare export type TextTrackWindowType = $Keys< + typeof TextTrackWindowTypeEnum, + >; + + declare export type TextTrackType = $Keys; + + declare export type TextTrackFontStyle = $Keys; + + declare export type TextTrackFontGenericFamily = $Keys< + typeof TextTrackFontGenericFamilyEnum, + >; + + declare export type TextTrackEdgeType = $Keys; + + declare export type StreamType = $Keys; + + declare export type StreamingProtocolType = $Keys< + typeof StreamingProtocolTypeEnum, + >; + + declare export type SeekResumeState = $Keys; + + declare export type Command = $Keys; + + declare export type ErrorReason = $Keys; + declare export type ErrorType = $Keys; + declare export type ExtendedPlayerState = $Keys< + typeof ExtendedPlayerStateEnum, + >; + + declare export type FocusState = $Keys; + + declare export type GetStatusOptions = $Keys; + + declare export type PlayStringId = $Keys; + + declare export type HdrType = $Keys; + + declare export type HlsSegmentFormat = $Keys; + + declare export type IdleReason = $Keys; + + declare export type RepeatMode = $Keys; + + declare export type MessageType = $Keys; + declare export type MetadataType = $Keys; + + declare export type QueueType = $Keys; + + declare export type QueueChangeType = $Keys; + + declare export type PlayerState = $Keys; + /** * RefreshCredentials request data. */ @@ -1671,7 +2156,7 @@ declare module 'cast.framework.messages' { * Describes track metadata information. */ declare export class Track { - constructor(trackId: number, trackType: TrackType): Track; + constructor(trackId: number, trackType: TrackType): void; /** * Custom data set by the receiver application. @@ -1811,7 +2296,7 @@ declare module 'cast.framework.messages' { /** * Optional request source. It contain the assistent query that initiate the request. */ - source?: string | null; + source?: string ; } /** @@ -2629,7 +3114,7 @@ declare module 'cast.framework.messages' { /** * Optional request source. It contain the assistent query that initiate the request. */ - source?: string | null; + source?: string ; } /** diff --git a/definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js b/definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js index 2a11686dc5..46196be925 100644 --- a/definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js +++ b/definitions/browser/chromecast-caf-receiver_v3.x.x/test_chromecast-caf-receiver_v3.x.x.js @@ -1,10 +1,12 @@ +// @flow import { TextTracksManager } from "cast.framework"; import { StandbyChangedEvent } from "cast.framework.system"; -import { PlayerData } from "cast.framework.ui"; +import { PlayerData, ContentType } from "cast.framework.ui"; import { BreakManager } from "cast.framework.breaks"; import { MediaStatusEvent } from "cast.framework.events"; import { Track, Break, MediaStatus, QueueData } from "cast.framework.messages"; +const ct = ContentType.VIDEO; // framework tests const track = new Track(123, {}); const ttm = new TextTracksManager({}); From 57936d569c8b64b45ef270b5b6e5e8e4f11e2ea5 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Wed, 14 Mar 2018 17:16:55 +0300 Subject: [PATCH 18/75] add setprototypeof definitions (#1960) --- .../flow_v0.25.x-/setprototypeof_v1.x.x.js | 3 +++ .../test_setprototypeof_v1.x.x.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/setprototypeof_v1.x.x.js create mode 100644 definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/test_setprototypeof_v1.x.x.js diff --git a/definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/setprototypeof_v1.x.x.js b/definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/setprototypeof_v1.x.x.js new file mode 100644 index 0000000000..526cf1d2b6 --- /dev/null +++ b/definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/setprototypeof_v1.x.x.js @@ -0,0 +1,3 @@ +declare module 'setprototypeof' { + declare module.exports: (o: T, proto: Object | null) => T; +} diff --git a/definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/test_setprototypeof_v1.x.x.js b/definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/test_setprototypeof_v1.x.x.js new file mode 100644 index 0000000000..1fa0fe2f6e --- /dev/null +++ b/definitions/npm/setprototypeof_v1.x.x/flow_v0.25.x-/test_setprototypeof_v1.x.x.js @@ -0,0 +1,19 @@ +// @flow + +import setprototypeof from 'setprototypeof'; + +const proto = {}; +setprototypeof({}, proto); +setprototypeof({}, null); + +// $ExpectError +setprototypeof({}); + +// $ExpectError +setprototypeof(123, NaN); + +// $ExpectError +setprototypeof({}, undefined); + +// $ExpectError +setprototypeof({}, 'invalid_arg_type'); From 0548e6fad89202463c10d7cb1ebb6e3968a3c815 Mon Sep 17 00:00:00 2001 From: Dimitri DO BAIRRO Date: Wed, 14 Mar 2018 15:56:39 +0100 Subject: [PATCH 19/75] fix(npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js) result type fixed (#1961) --- .../npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js b/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js index 17728fb4f3..fbecf9507a 100644 --- a/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js +++ b/definitions/npm/@sendgrid/mail_v6.x.x/flow_v0.30.x-/mail_v6.x.x.js @@ -131,7 +131,7 @@ declare module '@sendgrid/mail' { declare class MailService { setApiKey(apiKey: string): void; setSubstitutionWrappers(left: string, right: string): void; - send(data: MailData | MailData[], isMultiple?: boolean, cb?: (err: Error | ResponseError, result: [http$ClientRequest, {}]) => void): Promise<[http$ClientRequest, {}]>; + send(data: MailData | MailData[], isMultiple?: boolean, cb?: (err: Error | ResponseError, result: [http$ServerResponse, {}]) => void): Promise<[http$ServerResponse, {}]>; } declare export default MailService & { MailService: MailService }; From cab04034e78b06a8723de76f4d23b5b790803625 Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Thu, 15 Mar 2018 02:31:23 +1100 Subject: [PATCH 20/75] Corrected Redux v3.x.x createStore and Reducer definitions (#1958) --- .../npm/redux_v3.x.x/flow_v0.25.x-v0.27.x/redux_v3.x.x.js | 2 +- .../npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/redux_v3.x.x.js | 4 ++-- .../flow_v0.28.x-v0.32.x/test_applyMiddleware.js | 2 +- .../redux_v3.x.x/flow_v0.28.x-v0.32.x/test_createStore.js | 3 ++- .../npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/redux_v3.x.x.js | 4 ++-- .../flow_v0.33.x-v0.54.x/test_applyMiddleware.js | 2 +- .../redux_v3.x.x/flow_v0.33.x-v0.54.x/test_createStore.js | 3 ++- .../flow_v0.33.x-v0.54.x/test_custom_dispatch.js | 2 +- definitions/npm/redux_v3.x.x/flow_v0.55.x-/redux_v3.x.x.js | 6 +++--- .../npm/redux_v3.x.x/flow_v0.55.x-/test_applyMiddleware.js | 2 +- .../npm/redux_v3.x.x/flow_v0.55.x-/test_combineReducers.js | 6 ++++-- .../npm/redux_v3.x.x/flow_v0.55.x-/test_createStore.js | 3 ++- .../npm/redux_v3.x.x/flow_v0.55.x-/test_custom_dispatch.js | 2 +- 13 files changed, 23 insertions(+), 18 deletions(-) diff --git a/definitions/npm/redux_v3.x.x/flow_v0.25.x-v0.27.x/redux_v3.x.x.js b/definitions/npm/redux_v3.x.x/flow_v0.25.x-v0.27.x/redux_v3.x.x.js index 780e7e6dd1..498a04948a 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.25.x-v0.27.x/redux_v3.x.x.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.25.x-v0.27.x/redux_v3.x.x.js @@ -2,7 +2,7 @@ declare module "redux" { declare type State = any; declare type Action = Object; declare type AsyncAction = any; - declare type Reducer = (state: S, action: A) => S; + declare type Reducer = (state: S | void, action: A) => S; declare type BaseDispatch = (a: Action) => Action; declare type Dispatch = (a: Action | AsyncAction) => any; declare type ActionCreator = (...args: any) => Action | AsyncAction; diff --git a/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/redux_v3.x.x.js b/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/redux_v3.x.x.js index fc6708c574..cb93c59aa9 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/redux_v3.x.x.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/redux_v3.x.x.js @@ -22,7 +22,7 @@ declare module 'redux' { replaceReducer(nextReducer: Reducer): void }; - declare type Reducer = (state: S, action: A) => S; + declare type Reducer = (state: S | void, action: A) => S; declare type Middleware = (api: MiddlewareAPI) => @@ -36,7 +36,7 @@ declare module 'redux' { declare type StoreEnhancer = (next: StoreCreator) => StoreCreator; declare function createStore(reducer: Reducer, enhancer?: StoreEnhancer): Store; - declare function createStore(reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; + declare function createStore(reducer: Reducer, preloadedState?: S, enhancer?: StoreEnhancer): Store; declare function applyMiddleware(...middlewares: Array>): StoreEnhancer; diff --git a/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_applyMiddleware.js b/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_applyMiddleware.js index ca69e7dc1b..2711b07ea3 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_applyMiddleware.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_applyMiddleware.js @@ -5,7 +5,7 @@ import { applyMiddleware, createStore } from 'redux' type State = Array; type Action = { type: 'A' }; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // applyMiddleware API diff --git a/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_createStore.js b/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_createStore.js index 6eec952288..2aba101700 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_createStore.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.28.x-v0.32.x/test_createStore.js @@ -5,7 +5,7 @@ import { createStore } from 'redux' type State = Array; type Action = { type: 'A' }; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // createStore API @@ -24,6 +24,7 @@ const store6: Store = createStore(reducer, [1]); const store7: Store = createStore(reducer, [1], 'wrong'); // wrong enhancer declare var myEnhancer: StoreEnhancer; const store8: Store = createStore(reducer, [1], myEnhancer); +const store9: Store = createStore(reducer, undefined, myEnhancer); // // store members diff --git a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/redux_v3.x.x.js b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/redux_v3.x.x.js index 91bd57452c..bf62fa3b7b 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/redux_v3.x.x.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/redux_v3.x.x.js @@ -24,7 +24,7 @@ declare module 'redux' { replaceReducer(nextReducer: Reducer): void }; - declare export type Reducer = (state: S, action: A) => S; + declare export type Reducer = (state: S | void, action: A) => S; declare export type CombinedReducer = (state: $Shape & {} | void, action: A) => S; @@ -40,7 +40,7 @@ declare module 'redux' { declare export type StoreEnhancer> = (next: StoreCreator) => StoreCreator; declare export function createStore(reducer: Reducer, enhancer?: StoreEnhancer): Store; - declare export function createStore(reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; + declare export function createStore(reducer: Reducer, preloadedState?: S, enhancer?: StoreEnhancer): Store; declare export function applyMiddleware(...middlewares: Array>): StoreEnhancer; diff --git a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_applyMiddleware.js b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_applyMiddleware.js index ca69e7dc1b..2711b07ea3 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_applyMiddleware.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_applyMiddleware.js @@ -5,7 +5,7 @@ import { applyMiddleware, createStore } from 'redux' type State = Array; type Action = { type: 'A' }; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // applyMiddleware API diff --git a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_createStore.js b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_createStore.js index 6eec952288..2aba101700 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_createStore.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_createStore.js @@ -5,7 +5,7 @@ import { createStore } from 'redux' type State = Array; type Action = { type: 'A' }; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // createStore API @@ -24,6 +24,7 @@ const store6: Store = createStore(reducer, [1]); const store7: Store = createStore(reducer, [1], 'wrong'); // wrong enhancer declare var myEnhancer: StoreEnhancer; const store8: Store = createStore(reducer, [1], myEnhancer); +const store9: Store = createStore(reducer, undefined, myEnhancer); // // store members diff --git a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_custom_dispatch.js b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_custom_dispatch.js index ed88f77b61..1f8f2158e2 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_custom_dispatch.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.33.x-v0.54.x/test_custom_dispatch.js @@ -7,7 +7,7 @@ type Action = { type: 'A' }; type Thunk = (dispatch: Dispatch, getState: () => State) => void; type Dispatch = DispatchAPI; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // applyMiddleware interaction with createStore diff --git a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/redux_v3.x.x.js b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/redux_v3.x.x.js index 2acd6a4cd4..5d88cb53d9 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/redux_v3.x.x.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/redux_v3.x.x.js @@ -24,7 +24,7 @@ declare module 'redux' { replaceReducer(nextReducer: Reducer): void }; - declare export type Reducer = (state: S, action: A) => S; + declare export type Reducer = (state: S | void, action: A) => S; declare export type CombinedReducer = (state: $Shape & {} | void, action: A) => S; @@ -40,7 +40,7 @@ declare module 'redux' { declare export type StoreEnhancer> = (next: StoreCreator) => StoreCreator; declare export function createStore(reducer: Reducer, enhancer?: StoreEnhancer): Store; - declare export function createStore(reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; + declare export function createStore(reducer: Reducer, preloadedState?: S, enhancer?: StoreEnhancer): Store; declare export function applyMiddleware(...middlewares: Array>): StoreEnhancer; @@ -53,4 +53,4 @@ declare module 'redux' { declare export function combineReducers(reducers: O): CombinedReducer<$ObjMap(r: Reducer) => S>, A>; declare export var compose: $Compose; -} \ No newline at end of file +} diff --git a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_applyMiddleware.js b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_applyMiddleware.js index ca69e7dc1b..2711b07ea3 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_applyMiddleware.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_applyMiddleware.js @@ -5,7 +5,7 @@ import { applyMiddleware, createStore } from 'redux' type State = Array; type Action = { type: 'A' }; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // applyMiddleware API diff --git a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_combineReducers.js b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_combineReducers.js index 17cb7d9a61..ecbef53c68 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_combineReducers.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_combineReducers.js @@ -18,11 +18,13 @@ type State = { // combineReducers API // -function reducerName(name: string, action: Action): string { +const initialName = 'initialName' +function reducerName(name: string = initialName, action: Action): string { return name } -function reducerAge(age: number, action: Action): number { +const initialAge = 0 +function reducerAge(age: number = initialAge, action: Action): number { return age } diff --git a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_createStore.js b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_createStore.js index 6eec952288..2aba101700 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_createStore.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_createStore.js @@ -5,7 +5,7 @@ import { createStore } from 'redux' type State = Array; type Action = { type: 'A' }; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // createStore API @@ -24,6 +24,7 @@ const store6: Store = createStore(reducer, [1]); const store7: Store = createStore(reducer, [1], 'wrong'); // wrong enhancer declare var myEnhancer: StoreEnhancer; const store8: Store = createStore(reducer, [1], myEnhancer); +const store9: Store = createStore(reducer, undefined, myEnhancer); // // store members diff --git a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_custom_dispatch.js b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_custom_dispatch.js index ed88f77b61..1f8f2158e2 100644 --- a/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_custom_dispatch.js +++ b/definitions/npm/redux_v3.x.x/flow_v0.55.x-/test_custom_dispatch.js @@ -7,7 +7,7 @@ type Action = { type: 'A' }; type Thunk = (dispatch: Dispatch, getState: () => State) => void; type Dispatch = DispatchAPI; type Store = ReduxStore; -const reducer = (state: State, action: Action): State => state +const reducer = (state: State = [], action: Action): State => state // // applyMiddleware interaction with createStore From 03a2b580f4276413c380aec7b29ecbaa6d27240d Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Wed, 14 Mar 2018 17:15:44 -0700 Subject: [PATCH 21/75] Add firestore to firebase. Fixes gh-1657 (#1690) **Problem:** Firebase is missing Firestore definitions (gh-1657). **Solution:** Add them. Followed the official [Firestore reference documentation](https://firebase.google.com/docs/reference/js/firebase.firestore) --- .../flow_v0.34.x-/firebase_v4.x.x.js | 409 +++++++++++++----- .../flow_v0.34.x-/test_firebase.js | 132 +++++- 2 files changed, 407 insertions(+), 134 deletions(-) diff --git a/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js b/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js index bbf3d329f2..e333a66075 100644 --- a/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js +++ b/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js @@ -12,49 +12,49 @@ declare interface $npm$firebase$Config { declare interface $npm$firebase$auth$Error { code: - | "auth/app-deleted" - | "auth/app-not-authorized" - | "auth/argument-error" - | "auth/invalid-api-key" - | "auth/invalid-user-token" - | "auth/network-request-failed" - | "auth/operation-not-allowed" - | "auth/requires-recent-login" - | "auth/too-many-requests" - | "auth/unauthorized-domain" - | "auth/user-disabled" - | "auth/user-token-expired" - | "auth/web-storage-unsupported" - | "auth/invalid-email" - | "auth/account-exists-with-different-credential" - | "auth/invalid-credential" - | "auth/user-not-found" - | "auth/wrong-password" - | "auth/invalid-verification-code" - | "auth/invalid-verification-id" - | "auth/expired-action-code" - | "auth/invalid-action-code" - | "auth/invalid-verification-code" - | "auth/missing-verification-code" - | "auth/captcha-check-failed" - | "auth/invalid-phone-number" - | "auth/missing-phone-number" - | "auth/quota-exceeded" - | "auth/credential-already-in-use" - | "auth/email-already-in-use" - | "auth/provider-already-linked" - | "auth/auth-domain-config-required" - | "auth/cancelled-popup-request" - | "auth/popup-blocked" - | "auth/operation-not-supported-in-this-environment" - | "auth/popup-closed-by-user" - | "auth/unauthorized-domain" - | "auth/no-such-provider"; + | 'auth/app-deleted' + | 'auth/app-not-authorized' + | 'auth/argument-error' + | 'auth/invalid-api-key' + | 'auth/invalid-user-token' + | 'auth/network-request-failed' + | 'auth/operation-not-allowed' + | 'auth/requires-recent-login' + | 'auth/too-many-requests' + | 'auth/unauthorized-domain' + | 'auth/user-disabled' + | 'auth/user-token-expired' + | 'auth/web-storage-unsupported' + | 'auth/invalid-email' + | 'auth/account-exists-with-different-credential' + | 'auth/invalid-credential' + | 'auth/user-not-found' + | 'auth/wrong-password' + | 'auth/invalid-verification-code' + | 'auth/invalid-verification-id' + | 'auth/expired-action-code' + | 'auth/invalid-action-code' + | 'auth/invalid-verification-code' + | 'auth/missing-verification-code' + | 'auth/captcha-check-failed' + | 'auth/invalid-phone-number' + | 'auth/missing-phone-number' + | 'auth/quota-exceeded' + | 'auth/credential-already-in-use' + | 'auth/email-already-in-use' + | 'auth/provider-already-linked' + | 'auth/auth-domain-config-required' + | 'auth/cancelled-popup-request' + | 'auth/popup-blocked' + | 'auth/operation-not-supported-in-this-environment' + | 'auth/popup-closed-by-user' + | 'auth/unauthorized-domain' + | 'auth/no-such-provider'; message: string; } declare interface $npm$firebase$Error { - code: $PropertyType<$npm$firebase$auth$Error, "code"> | "app/no-app"; + code: $PropertyType<$npm$firebase$auth$Error, 'code'> | 'app/no-app'; message: string; name: string; stack: ?string; @@ -297,11 +297,11 @@ declare type $npm$firebase$database$OnCompleteCallback = ( error: ?Object ) => void; declare type $npm$firebase$database$QueryEventType = - | "value" - | "child_added" - | "child_changed" - | "child_removed" - | "child_moved"; + | 'value' + | 'child_added' + | 'child_changed' + | 'child_removed' + | 'child_moved'; declare type $npm$firebase$database$Priority = string | number | null; declare class $npm$firebase$database$Database { @@ -442,19 +442,190 @@ declare class $npm$firebase$database$ServerValue { declare class $npm$firebase$database$ThenableReference extends $npm$firebase$database$Reference {} +/** **** firestore ******/ +declare class $npm$firebase$firestore$Firestore { + app: $npm$firebase$App; + batch(): $npm$firebase$firestore$WriteBatch; + collection(collectionPath: string): $npm$firebase$firestore$CollectionReference; + doc(documentPath: string): $npm$firebase$firestore$DocumentReference; + enablePersistence(): Promise; + runTransaction(updateFunction: (transaction: $npm$firebase$firestore$Transaction) => Promise): Promise; + setLogLevel(logLevel: 'debug' | 'error' | 'silent'): void; + settings(settings: $npm$firebase$firestore$Settings): void; +} + +declare interface $npm$firebase$firestore$Blob { + fromBase64String(base64: string): $npm$firebase$firestore$Blob; + fromUint8Array(array: Uint8Array): $npm$firebase$firestore$Blob; + toBase64(): string; + toUintArray(): Uint8Array; +} + +declare interface $npm$firebase$firestore$QueryListenOptions { + includeMetadataChanges: boolean; + includeQueryMetadataChanges: boolean; +} +declare type $npm$firebase$firestore$observer = (snapshot: $npm$firebase$firestore$DocumentSnapshot) => void; +declare type $npm$firebase$firestore$observerError = (error: $npm$firebase$Error) => void; + +declare class $npm$firebase$firestore$Query { + firestore: $npm$firebase$firestore$Firestore; + endAt(snapshotOrVarArgs: $npm$firebase$firestore$DocumentSnapshot | {}): $npm$firebase$firestore$Query; + endBefore(snapshotOrVarArgs: $npm$firebase$firestore$DocumentSnapshot | {}): $npm$firebase$firestore$Query; + get(): Promise<$npm$firebase$firestore$QuerySnapshot>; + limit(limit: number): $npm$firebase$firestore$Query; + onSnapshot( + optionsOrObserverOrOnNext: $npm$firebase$firestore$QueryListenOptions | $npm$firebase$firestore$observer, + observerOrOnNextOrOnError?: | $npm$firebase$firestore$QueryListenOptions + | $npm$firebase$firestore$observer + | $npm$firebase$firestore$observerError, + onError?: $npm$firebase$firestore$observerError + ): void; + orderBy( + fieldPath: $npm$firebase$firestore$FieldPath | string, + directionStr: 'asc' | 'desc' + ): $npm$firebase$firestore$Query; + startAfter(snapshotOrVarArgs: $npm$firebase$firestore$DocumentSnapshot | {}): $npm$firebase$firestore$Query; + startAt(snapshotOrVarArgs: $npm$firebase$firestore$DocumentSnapshot | {}): $npm$firebase$firestore$Query; + where(fieldPath: string, opStr: '<' | '<=' | '==' | '>' | '>=', value: any): $npm$firebase$firestore$Query; +} + +declare class $npm$firebase$firestore$CollectionReference extends $npm$firebase$firestore$Query { + constructor(): $npm$firebase$firestore$CollectionReference; + id: string; + parent: $npm$firebase$firestore$DocumentReference | null; + add(data: {}): Promise; + doc(documentPath?: string): $npm$firebase$firestore$DocumentReference; +} + +declare interface $npm$firebase$firestore$DocumentChange { + type: 'added' | 'removed' | 'modified'; +} + +declare class $npm$firebase$firestore$DocumentReference { + firestore: $npm$firebase$firestore$Firestore; + id: string; + parent: typeof $npm$firebase$firestore$CollectionReference; + collection(collectionPath: string): typeof $npm$firebase$firestore$CollectionReference; + delete(): Promise; + get(): Promise<$npm$firebase$firestore$DocumentSnapshot>; + onSnapshot( + optionsOrObserverOrOnNext: $npm$firebase$firestore$QueryListenOptions | $npm$firebase$firestore$observer, + observerOrOnNextOrOnError?: | $npm$firebase$firestore$QueryListenOptions + | $npm$firebase$firestore$observer + | $npm$firebase$firestore$observerError, + onError?: $npm$firebase$firestore$observerError + ): void; + set(data: {}, options?: { merge: boolean } | null): Promise; + update(...args: Array): Promise; +} + +declare class $npm$firebase$firestore$DocumentSnapshot { + data(): {}; + get(fieldpath: typeof $npm$firebase$firestore$FieldPath): any; + exists: boolean; + id: string; + metadata: $npm$firebase$firestore$SnapshotMetadata; + ref: $npm$firebase$firestore$DocumentReference; +} + +declare class $npm$firebase$firestore$FieldPath { + constructor(...args: Array): $npm$firebase$firestore$FieldPath; + documentId(): typeof $npm$firebase$firestore$FieldPath; +} + +declare interface $npm$firebase$firestore$FieldValue { + delete(): $npm$firebase$firestore$FieldValue; + serverTimestamp(): $npm$firebase$firestore$FieldValue; +} + +declare type $npm$firebase$firestore$FirestoreError = + | 'cancelled' + | 'unknown' + | 'invalid-argument' + | 'deadline-exceeded' + | 'not-found' + | 'already-exists' + | 'permission-denied' + | 'resource-exhausted' + | 'failed-precondition' + | 'aborted' + | 'out-of-range' + | 'unimplemented' + | 'internal' + | 'unavailable' + | 'data-loss' + | 'unauthenticated'; + +declare class $npm$firebase$firestore$GeoPoint { + constructor(latitude: number, longitude: number): $npm$firebase$firestore$GeoPoint; + latitude: number; + longitude: number; +} + +declare class $npm$firebase$firestore$QuerySnapshot { + docChanges(): Array<$npm$firebase$firestore$DocumentChange>; + docs: Array<$npm$firebase$firestore$DocumentSnapshot>; + empty: boolean; + metadata: $npm$firebase$firestore$SnapshotMetadata; + query: $npm$firebase$firestore$Query; + size: number; + forEach((snapshot: $npm$firebase$firestore$DocumentSnapshot, thisArg?: any) => void): void; +} + +declare interface $npm$firebase$firestore$Settings {} + +declare interface $npm$firebase$firestore$SnapshotMetadata { + fromCache: boolean; + hasPendingWrites: boolean; +} + +declare interface $npm$firebase$firestore$Transaction { + delete(documentRef: $npm$firebase$firestore$DocumentReference): $npm$firebase$firestore$Transaction; + get(documentRef: $npm$firebase$firestore$DocumentReference): Promise<$npm$firebase$firestore$DocumentSnapshot>; + set( + documentRef: $npm$firebase$firestore$DocumentReference, + data: {}, + options?: { merge: boolean } + ): $npm$firebase$firestore$Transaction; + update(documentRef: $npm$firebase$firestore$DocumentReference, ...args: Array): $npm$firebase$firestore$Transaction; +} + +declare interface $npm$firebase$firestore$WriteBatch { + commit(): Promise; + delete(documentRef: $npm$firebase$firestore$DocumentReference): $npm$firebase$firestore$WriteBatch; + set( + documentRef: $npm$firebase$firestore$DocumentReference, + data: {}, + options?: { merge: boolean } + ): $npm$firebase$firestore$WriteBatch; + update(documentRef: $npm$firebase$firestore$DocumentReference, ...args: Array): $npm$firebase$firestore$WriteBatch; +} + +/** **** messaging ******/ +declare class $npm$firebase$messaging$Messaging { + deleteToken(token: string): Promise; + getToken(): Promise; + onMessage(nextOrObserver: ({}) => void | {}): () => void; + onTokenRefresh(nextOrObserver: ({}) => void | {}): () => void; + requestPermission(): Promise; + setBackgroundMessageHandler(callback: (value: {}) => void): void; + useServiceWorker(registration: any): void; +} + /** **** storage ******/ declare type $npm$firebase$storage$StringFormat = - | "raw" - | "base64" - | "base64url" - | "data_url"; -declare type $npm$firebase$storage$TaskEvent = "state_changed"; + | 'raw' + | 'base64' + | 'base64url' + | 'data_url'; +declare type $npm$firebase$storage$TaskEvent = 'state_changed'; declare type $npm$firebase$storage$TaskState = - | "running" - | "paused" - | "success" - | "canceled" - | "error"; + | 'running' + | 'paused' + | 'success' + | 'canceled' + | 'error'; declare class $npm$firebase$storage$Storage { app: $npm$firebase$App; @@ -526,9 +697,8 @@ declare interface $npm$firebase$storage$Observer { declare type $npm$firebase$storage$Unsubscribe = () => void; declare type $npm$firebase$storage$Subscribe = ( - observerOrNext: - | $npm$firebase$storage$Observer - | ((snapshot: $npm$firebase$storage$UploadTaskSnapshot) => void), + observerOrNext: | $npm$firebase$storage$Observer + | ((snapshot: $npm$firebase$storage$UploadTaskSnapshot) => void), onError?: (error: Error) => void, onComplete?: () => void ) => $npm$firebase$storage$Unsubscribe; @@ -544,9 +714,8 @@ declare class $npm$firebase$storage$UploadTask extends Promise< ): $npm$firebase$storage$Subscribe; on( event: $npm$firebase$storage$TaskEvent, - observerOrNext: - | $npm$firebase$storage$Observer - | ((snapshot: $npm$firebase$storage$UploadTaskSnapshot) => void), + observerOrNext: | $npm$firebase$storage$Observer + | ((snapshot: $npm$firebase$storage$UploadTaskSnapshot) => void), onError?: (error: Error) => void, onComplete?: () => void ): $npm$firebase$storage$Unsubscribe; @@ -565,7 +734,7 @@ declare class $npm$firebase$storage$UploadTaskSnapshot { } // Exporting the types -declare module "firebase" { +declare module 'firebase' { declare module.exports: { +apps: Array<$npm$firebase$App>, initializeApp( @@ -577,61 +746,43 @@ declare module "firebase" { FirebaseConfig: $npm$firebase$Config, FirebaseUser: typeof $npm$firebase$auth$User, FirebaseUserInfo: typeof $npm$firebase$auth$UserInfo, - app: { - (name?: string): typeof $npm$firebase$App, - App: typeof $npm$firebase$App - }, - auth: { - (app?: $npm$firebase$App): $npm$firebase$auth$Auth, - FirebaseAdditionalUserInfo: $npm$firebase$auth$AdditionalUserInfo, - FirebaseUserCredential: $npm$firebase$auth$UserCredential, - ActionCodeInfo: $npm$firebase$auth$ActionCodeInfo, - ApplicationVerifier: $npm$firebase$auth$ApplicationVerifier, - Auth: typeof $npm$firebase$auth$Auth, - AuthCredential: $npm$firebase$auth$AuthCredential, - AuthProvider: $npm$firebase$auth$AuthProvider, - ConfirmationResult: $npm$firebase$auth$ConfirmationResult, - EmailAuthProvider: typeof $npm$firebase$auth$EmailAuthProvider, - Error: $npm$firebase$auth$Error, - FacebookAuthProvider: typeof $npm$firebase$auth$FacebookAuthProvider, - GithubAuthProvider: typeof $npm$firebase$auth$GithubAuthProvider, - GoogleAuthProvider: typeof $npm$firebase$auth$GoogleAuthProvider, - PhoneAuthProvider: typeof $npm$firebase$auth$PhoneAuthProvider, - TwitterAuthProvider: typeof $npm$firebase$auth$TwitterAuthProvider - }, - database: { - (app?: $npm$firebase$App): $npm$firebase$database$Database, - enableLogging( - logger?: boolean | ((msg: string) => void), - persistent?: boolean - ): void, - DataSnapshot: typeof $npm$firebase$database$DataSnapshot, - Database: typeof $npm$firebase$database$Database, - OnDisconnect: typeof $npm$firebase$database$OnDisconnect, - Query: typeof $npm$firebase$database$Query, - Reference: typeof $npm$firebase$database$Reference, - ServerValue: typeof $npm$firebase$database$ServerValue, - ThenableReference: typeof $npm$firebase$database$ThenableReference - }, - storage: { - (app?: $npm$firebase$App): $npm$firebase$storage$Storage, - Storage: typeof $npm$firebase$storage$Storage, - FullMetadata: typeof $npm$firebase$storage$FullMetadata, - Reference: typeof $npm$firebase$storage$Reference, - SettableMetadata: typeof $npm$firebase$storage$SettableMetadata, - UploadMetadata: typeof $npm$firebase$storage$UploadMetadata, - UploadTask: typeof $npm$firebase$storage$UploadTask, - UploadTaskSnapshot: typeof $npm$firebase$storage$UploadTaskSnapshot - } + app: $Exports<'@firebase/app'>, + auth: $Exports<'@firebase/auth'>, + database: $Exports<'@firebase/database'>, + firestore: $Exports<'@firebase/firestore'>, + messaging: $Exports<'@firebase/messaging'>, + storage: $Exports<'@firebase/storage'> }; } -declare module "firebase/app" { + +declare module 'firebase/app' { + declare module.exports: $Exports<'@firebase/app'>; +} + +declare module 'firebase/auth' { + declare module.exports: $Exports<'@firebase/auth'> +} + +declare module 'firebase/database' { + declare module.exports: $Exports<'@firebase/database'>; +} + +declare module 'firebase/firestore' { + declare module.exports: $Exports<'@firebase/firestore'>; +} + +declare module 'firebase/messaging' { + declare module.exports: $Exports<'@firebase/messaging'>; +} + +declare module '@firebase/app' { declare module.exports: { (name?: string): $npm$firebase$App, App: typeof $npm$firebase$App }; } -declare module "firebase/auth" { + +declare module '@firebase/auth' { declare module.exports: { (app?: $npm$firebase$App): $npm$firebase$auth$Auth, FirebaseAdditionalUserInfo: $npm$firebase$auth$AdditionalUserInfo, @@ -651,7 +802,12 @@ declare module "firebase/auth" { TwitterAuthProvider: typeof $npm$firebase$auth$TwitterAuthProvider }; } -declare module "firebase/database" { + +declare module 'firebase/storage' { + declare module.exports: $Exports<'firebase/storage'>; +} + +declare module '@firebase/database' { declare module.exports: { (app?: $npm$firebase$App): $npm$firebase$database$Database, enableLogging( @@ -667,7 +823,38 @@ declare module "firebase/database" { ThenableReference: typeof $npm$firebase$database$ThenableReference }; } -declare module "firebase/storage" { + +declare module '@firebase/firestore' { + declare module.exports: { + (app?: $npm$firebase$App): $npm$firebase$firestore$Firestore, + Blob: $npm$firebase$firestore$Blob, + CollectionReference: typeof $npm$firebase$firestore$CollectionReference, + DocumentChange: $npm$firebase$firestore$DocumentChange, + DocumentReference: typeof $npm$firebase$firestore$DocumentReference, + DocumentSnapshot: typeof $npm$firebase$firestore$DocumentSnapshot, + FieldPath: typeof $npm$firebase$firestore$FieldPath, + FieldValue: $npm$firebase$firestore$FieldValue, + Firestore: typeof $npm$firebase$firestore$Firestore, + FirestoreError: $npm$firebase$firestore$FirestoreError, + GeoPoint: typeof $npm$firebase$firestore$GeoPoint, + Query: typeof $npm$firebase$firestore$Query, + QueryListenOptions: $npm$firebase$firestore$QueryListenOptions, + QuerySnapshot: typeof $npm$firebase$firestore$QuerySnapshot, + Settings: $npm$firebase$firestore$Settings, + SnapshotMetadata: $npm$firebase$firestore$SnapshotMetadata, + Transaction: $npm$firebase$firestore$Transaction, + WriteBatch: $npm$firebase$firestore$WriteBatch + }; +} + +declare module '@firebase/messaging' { + declare module.exports: { + (app?: $npm$firebase$App): $npm$firebase$messaging$Messaging, + Messaging: $npm$firebase$messaging$Messaging + }; +} + +declare module '@firebase/storage' { declare module.exports: { (app?: $npm$firebase$App): $npm$firebase$storage$Storage, Storage: typeof $npm$firebase$storage$Storage, diff --git a/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/test_firebase.js b/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/test_firebase.js index 72a30317ba..31287fb544 100644 --- a/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/test_firebase.js +++ b/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/test_firebase.js @@ -1,6 +1,7 @@ // @flow -import * as firebase from "firebase"; +import firebase from "firebase"; +import "firebase/firestore"; import app from "firebase/app"; import auth from "firebase/auth"; import database from "firebase/database"; @@ -58,14 +59,17 @@ firebase // #7 const provider = new firebase.auth.GithubAuthProvider(); -firebase.auth().currentUser.linkWithPopup(provider).then(result => { - result.credential; - result.additionalUserInfo; - result.operationType; - result.user; - // $ExpectError - result.foobar; -}); +firebase + .auth() + .currentUser.linkWithPopup(provider) + .then(result => { + result.credential; + result.additionalUserInfo; + result.operationType; + result.user; + // $ExpectError + result.foobar; + }); // #8 const provider2 = new firebase.auth.EmailAuthProvider(); @@ -94,18 +98,26 @@ firebase .then(() => firebase.auth().signInWithCredential(credential)); // #10 -firebase.database().ref("users/42").set({ username: "foobar" }); +firebase + .database() + .ref("users/42") + .set({ username: "foobar" }); // #11 -firebase.database().ref("users/42").on("value", snp => { - snp.val(); -}); +firebase + .database() + .ref("users/42") + .on("value", snp => { + snp.val(); + }); // #12 -firebase.database().ref("users/42")// $ExpectError -.on("foo", snp => { - snp.val(); -}); +firebase + .database() + .ref("users/42") // $ExpectError + .on("foo", snp => { + snp.val(); + }); // #13 firebase @@ -117,11 +129,18 @@ firebase .then(snp => snp.forEach(_ => true)); // #14 -firebase.database().ref("users/42").orderByKey()// $ExpectError -.limitToLast("foo"); +firebase + .database() + .ref("users/42") + .orderByKey() // $ExpectError + .limitToLast("foo"); // #15 -firebase.storage().ref().child("foo").child("bar"); +firebase + .storage() + .ref() + .child("foo") + .child("bar"); // #17 firebase @@ -148,11 +167,16 @@ firebase .catch(); // #19 -firebase.storage().ref("/foo")// $ExpectError -.put("foobar"); +firebase + .storage() + .ref("/foo") // $ExpectError + .put("foobar"); // #20 -const task = firebase.storage().ref("/foo").put(new File(["foo"], "foo.txt")); +const task = firebase + .storage() + .ref("/foo") + .put(new File(["foo"], "foo.txt")); const subscribe = task.on("state_changed"); const unsubscribe = subscribe(snp => { (snp.bytesTransferred: number); @@ -193,3 +217,65 @@ firebase.auth().setPersistence('local'); firebase.auth().setPersistence(firebase.auth.Auth.Persistence.FOO); // $ExpectError firebase.auth().setPersistence('foo'); + +firebase + .firestore() + .doc("/foo/bar") + .get() + .then(snapshot => { + (snapshot.id: string); + // $ExpectError + snapshot.foo; + }) + .catch(); + +// #24 +firebase + .firestore() + .doc("/foo/bar") + .get() + .then(snapshot => { + (snapshot.id: string); + // $ExpectError + snapshot.foo; + // $ExpectError + snapshot.forEach((snapshot) => {}); + }) + .catch(); + +// #25 +(firebase.firestore().doc("/foo/bar").id: string); + +// #26 +// $ExpectError +firebase.firestore().doc("/foo/bar").limit(4); + +// #27 +firebase + .firestore() + .collection("/foo/bar") + .get() + .then(snapshots => { + snapshots.forEach(snapshot => { (snapshot.id: string) }); + // $ExpectError + snapshots.foo; + }) + .catch(); + +// #28 +firebase + .firestore() + .collection("/foo") + .limit(4) + .endAt({ foo: 4 }) + .endBefore({ bar: 5 }) + .startAt({ foo: 1 }) + .startAfter({ bar: 2 }) + .orderBy(new firebase.firestore.FieldPath("foo", "bar"), "asc") + .get() + .then(snapshots => { + snapshots.forEach(snapshot => { (snapshot.id: string) }); + // $ExpectError + snapshots.foo; + }) + .catch(); From affc1c320ff454e190486d662851d52f8b29806b Mon Sep 17 00:00:00 2001 From: stouf Date: Fri, 16 Mar 2018 04:12:28 +0900 Subject: [PATCH 22/75] Fix the type of Knex$Transaction.rollback (#1947) --- definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js | 2 +- definitions/npm/knex_v0.13.x/test_knex-v0.13.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js b/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js index 387d6707d8..925194bd9f 100644 --- a/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js +++ b/definitions/npm/knex_v0.13.x/flow_v0.38.x-/knex_v0.13.x.js @@ -1,7 +1,7 @@ declare class Knex$Transaction mixins Knex$QueryBuilder, events$EventEmitter, Promise { commit(connection?: any, value?: any): Promise; - rollback(): Promise; + rollback(?Error): Promise; savepoint(connection?: any): Promise; } diff --git a/definitions/npm/knex_v0.13.x/test_knex-v0.13.js b/definitions/npm/knex_v0.13.x/test_knex-v0.13.js index 1f102a6da3..873b6e5b3d 100644 --- a/definitions/npm/knex_v0.13.x/test_knex-v0.13.js +++ b/definitions/npm/knex_v0.13.x/test_knex-v0.13.js @@ -69,6 +69,11 @@ knex .then(function(result) {}) .catch(function(err) {}); +knex + .transaction(function(trx) { + trx.rollback(); + }); + /** * knex is also an event emitter, * See : http://knexjs.org/#Interfaces-Events From 38661790d076df101534d3e495982f20a38f674b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 15 Mar 2018 18:06:06 -0400 Subject: [PATCH 23/75] Allow any file type in first level definition folder (#1962) * Allow any file type in first level definition folder * Fixed specs --- cli/src/lib/libDefs.js | 25 ++++---------------- cli/src/lib/npm/__tests__/npmLibDefs-test.js | 24 ------------------- cli/src/lib/npm/npmLibDefs.js | 15 +----------- 3 files changed, 6 insertions(+), 58 deletions(-) diff --git a/cli/src/lib/libDefs.js b/cli/src/lib/libDefs.js index 0f6efc9918..3519f302ad 100644 --- a/cli/src/lib/libDefs.js +++ b/cli/src/lib/libDefs.js @@ -27,7 +27,7 @@ export type LibDef = {| testFilePaths: Array, |}; -export const TEST_FILE_NAME_RE = /(^test_.*\.js$|^.*\.md$)/; +export const TEST_FILE_NAME_RE = /^test_.*\.js$/; const CACHE_DIR = path.join(os.homedir(), '.flow-typed'); const CACHE_REPO_DIR = path.join(CACHE_DIR, 'repo'); @@ -238,11 +238,7 @@ async function parseLibDefsFromPkgDir( return; } - const isValidTestFile = validateTestFile( - pkgDirItemPath, - pkgDirItemContext, - validationErrs, - ); + const isValidTestFile = validateTestFile(pkgDirItemPath); if (isValidTestFile) { commonTestFiles.push(pkgDirItemPath); @@ -294,11 +290,7 @@ async function parseLibDefsFromPkgDir( return; } - const isValidTestFile = validateTestFile( - flowDirItemPath, - flowDirItemContext, - validationErrs, - ); + const isValidTestFile = validateTestFile(flowDirItemPath); if (isValidTestFile) { testFilePaths.push(flowDirItemPath); @@ -374,16 +366,9 @@ export function parseRepoDirItem( /** * Given a path to an assumed test file, ensure that it is named as expected. */ -function validateTestFile(testFilePath, context, validationErrs) { +function validateTestFile(testFilePath) { const testFileName = path.basename(testFilePath); - if (!TEST_FILE_NAME_RE.test(testFileName)) { - const error = - 'Malformed test file name! Test files must be formatted as test_(.*).js: ' + - testFileName; - validationError(context, error, validationErrs); - return false; - } - return true; + return TEST_FILE_NAME_RE.test(testFileName); } /** diff --git a/cli/src/lib/npm/__tests__/npmLibDefs-test.js b/cli/src/lib/npm/__tests__/npmLibDefs-test.js index db38c51976..5baa2c606e 100644 --- a/cli/src/lib/npm/__tests__/npmLibDefs-test.js +++ b/cli/src/lib/npm/__tests__/npmLibDefs-test.js @@ -146,23 +146,6 @@ describe('npmLibDefs', () => { 'npm', 'underscore_v1.x.x', ); - const defsPromise1 = extractLibDefsFromNpmPkgDir( - UNDERSCORE_PATH, - null, - 'underscore_v1.x.x', - ); - let err = null; - try { - await defsPromise1; - } catch (e) { - err = e; - } - expect(err && err.message).toBe( - path.join('underscore_v1.x.x', 'asdf') + - ': Unexpected file name. This directory can ' + - 'only contain test files or a libdef file named `underscore_v1.x.x.js`.', - ); - const errs = new Map(); const defsPromise2 = extractLibDefsFromNpmPkgDir( UNDERSCORE_PATH, @@ -172,13 +155,6 @@ describe('npmLibDefs', () => { ); expect((await defsPromise2).length).toBe(2); expect([...errs.entries()]).toEqual([ - [ - path.join('underscore_v1.x.x', 'asdf'), - [ - 'Unexpected file name. This directory can only contain test files ' + - 'or a libdef file named `underscore_v1.x.x.js`.', - ], - ], [ 'underscore_v1.x.x/asdfdir', ['Flow versions must start with `flow_`'], diff --git a/cli/src/lib/npm/npmLibDefs.js b/cli/src/lib/npm/npmLibDefs.js index d15403ed6d..cffd4a2aa9 100644 --- a/cli/src/lib/npm/npmLibDefs.js +++ b/cli/src/lib/npm/npmLibDefs.js @@ -101,21 +101,8 @@ async function extractLibDefsFromNpmPkgDir( const pkgDirItemStat = fs.statSync(pkgDirItemPath); if (pkgDirItemStat.isFile()) { - if (path.extname(pkgDirItem) === '.swp') { - return; - } - const isValidTestFile = TEST_FILE_NAME_RE.test(pkgDirItem); - - if (isValidTestFile) { - commonTestFiles.push(pkgDirItemPath); - return; - } - - const error = - `Unexpected file name. This directory can only contain test files ` + - `or a libdef file named ${'`' + libDefFileName + '`'}.`; - validationError(pkgDirItemContext, error, validationErrors); + if (isValidTestFile) commonTestFiles.push(pkgDirItemPath); } else if (pkgDirItemStat.isDirectory()) { const errCount = validationErrors == null ? 0 : validationErrors.size; const parsedFlowDir = parseFlowDirString( From 26b23f11651ee9682dd6e0ea949533ba3f7b3219 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 16 Mar 2018 05:31:27 -0700 Subject: [PATCH 24/75] Clarify that raw React types can be used in libdefs. (#1956) --- CONTRIBUTING.md | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4da5aeb48a..9c595fa574 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,8 +8,8 @@ to existing libdefs. * [Contributing to the definitions repository](#contributing-to-the-definitions-repository) * [Writing libdefs tips](#writing-libdefs-tips) - * [Avoid `any` when possible](#avoid-any-when-possible) * [Don't import types from other libdefs](#dont-import-types-from-other-libdefs) + * [Avoid `any` when possible](#avoid-any-when-possible) * [Always prefix global variables that aren't really meant to be global](#prefix-global-variables-that-arent-really-meant-to-be-global) * [Writing tests](#writing-tests) * [Use `describe` and `it` blocks to limit scope](#use-describe-and-it-blocks-to-limit-scope) @@ -91,6 +91,23 @@ You know how to do it. ## Writing libdefs tips +### Don't import types from other libdefs + +You might think it would be possible to import types from other libdefs, much the same way you do in your own code: + +```js +import type { MyType } from 'some-module'; +declare module 'other-module' { + declare export function takesMyType(val: MyType): number; +} +``` + +...but you would be wrong. Flow silently converts `MyType` to be typed `any`, and then sadness ensues. + +You can use the raw, private React types (e.g. `React$Node`, `React$ComponentType`) directly without importing them, however. + +Currently it's not possible to safely import types from other libdefs when making your libdef. [Further discussion here](https://github.com/flowtype/flow-typed/issues/1857). + ### Avoid `any` when possible Using the `any` type for a variable or interface results in the loss of type information as types pass through it. That means if a type passes through `any` before propogating on to other code, the `any` will potentially cause Flow to miss type errors! @@ -157,21 +174,6 @@ getUser((user) => console.log('Got the user!')); Using `mixed` in place of `any` for the return type of a function or the type of a variable is a judgement call, though. Return types and declared variables flow into users' programs, which means that users will have to prove the type of `mixed` before they can use them. -### Don't import types from other libdefs - -You might think it would be possible to import types from other libdefs, much the same way you do in your own code: - -```js -import type { MyType } from 'some-module'; -declare module 'other-module' { - declare export function takesMyType(val: MyType): number; -} -``` - -...but you would be wrong. Flow silently converts `MyType` to be typed `any`, and then sadness ensues. - -Currently it's not possible to safely import types from other libdefs when making your libdef. [Further discussion here](https://github.com/flowtype/flow-typed/issues/1857). - ### Prefix global variables that aren't really meant to be global Right now we don't have a good way to write types inside `declare module {}` bodies that *aren't* exported. This problem is being worked on, but in the meantime the best option is to just put a declaration outside the `declare module {}` and reference it. From 22991d68f3dc6c353d8ea72a13b2d174d34d67b1 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Fri, 16 Mar 2018 10:10:43 -0400 Subject: [PATCH 25/75] Adds changelog, starting at 2.4.0 (#1966) --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..289445560e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,28 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [2.4.0] - 2018-03-16 + +### IMPORTANT + +A week after this release, all previous versions of `flow-typed` on npm will be DEPRECATED, in order to encourage upgrading to version `2.4.0`. After which, we will be introducing files to definition folders under `/definitions/npm`, which will break the `search`, `install` and `validate-defs` commands. + +**We strongly recommend upgrading to `2.4.0` within that timeframe.** + +### Added +- Allow any file type (.md, .json) under `/definitions/npm/_vx.x.x/` (#1962) +- `describe` and `it` can now be importing from `'flow-typed-test'` in `_test` files (#1942) + - See [CONTRIBUTING.md](https://github.com/flowtype/flow-typed/blob/master/CONTRIBUTING.md) +- Root directory option (-rootDir) to install command (#1835) + +### Changed +- Replace `unzip` with `unzipper` (#1957) + +### Fixed +- Fix jest specs breaking by adding `babel-core` as a dependency (#1864) From 08201de0d6716d970970ac90734d21cd57b9fe7b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Fri, 16 Mar 2018 10:41:20 -0400 Subject: [PATCH 26/75] v2.4.0 --- cli/package.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cli/package.json b/cli/package.json index fafce41ddb..1816726180 100644 --- a/cli/package.json +++ b/cli/package.json @@ -10,7 +10,7 @@ "bugs": { "url": "https://github.com/flowtype/flow-typed/issues" }, - "version": "2.3.0", + "version": "2.4.0", "main": "dist/cli.js", "bin": "dist/cli.js", "scripts": { @@ -59,13 +59,18 @@ "prettier": "^1.9.2", "regenerator-runtime": "^0.11.1" }, - "keywords": ["flow", "flowtype"], + "keywords": [ + "flow", + "flowtype" + ], "jest": { "name": "flow-typed-cli", "modulePathIgnorePatterns": [ "/dist/.*", "/node_modules/.*" ], - "testPathIgnorePatterns": ["/.*/__[^/]*-fixtures__/.*"] + "testPathIgnorePatterns": [ + "/.*/__[^/]*-fixtures__/.*" + ] } } From 23d4ce4cc3d0ac6d67ddf0dcec2796a8496eb41a Mon Sep 17 00:00:00 2001 From: rifflock Date: Fri, 16 Mar 2018 09:37:37 -0700 Subject: [PATCH 27/75] Add 'ready' function to bee-queue_v1.x.x supporting both callbacks and promises (#1967) --- .../npm/bee-queue_v1.x.x/flow_v0.25.0-/bee-queue_v1.x.x.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/definitions/npm/bee-queue_v1.x.x/flow_v0.25.0-/bee-queue_v1.x.x.js b/definitions/npm/bee-queue_v1.x.x/flow_v0.25.0-/bee-queue_v1.x.x.js index 6d7dda6aa4..640177b91a 100644 --- a/definitions/npm/bee-queue_v1.x.x/flow_v0.25.0-/bee-queue_v1.x.x.js +++ b/definitions/npm/bee-queue_v1.x.x/flow_v0.25.0-/bee-queue_v1.x.x.js @@ -62,6 +62,8 @@ declare class BeeQueue$Queue extends events$EventEmitter { paused: boolean, process(handler: BeeQueue$Handler): void, process(concurrency: number, handler: BeeQueue$Handler): void, + ready(): Promise<*>, + ready(cb: function): void, removeJob(jobId: number): Promise<*>, removeJob(jobId: number, callback: (err: ?Error) => void): void, settings: {} From fa010af9306bd5f2835c7890638afb0cb107dcfe Mon Sep 17 00:00:00 2001 From: Logan Barnett Date: Fri, 16 Mar 2018 15:22:15 -0700 Subject: [PATCH 28/75] ramda: use `$Values` to represent the values function (#1971) * ramda: use $Values to represent the values function * use new describe/it convention for tests --- .../flow_v0.62.x-/ramda_v0.x.x.js | 4 +-- .../flow_v0.62.x-/test_ramda_v0.x.x_object.js | 30 +++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js index 3822513a56..d304848123 100644 --- a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js +++ b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/ramda_v0.x.x.js @@ -1705,7 +1705,7 @@ declare module ramda { o: O ): Array<[string, T]>; - declare function values(o: O): Array; + declare function values(o: T): Array<$Values>; declare function valuesIn(o: O): Array; @@ -2073,4 +2073,4 @@ declare module ramda { fn: (x: S) => V, x: T | S ): T | V; -} \ No newline at end of file +} diff --git a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js index 557f4efc7b..df70d99d91 100644 --- a/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js +++ b/definitions/npm/ramda_v0.x.x/flow_v0.62.x-/test_ramda_v0.x.x_object.js @@ -1,6 +1,16 @@ /* @flow */ /*eslint-disable no-undef, no-unused-vars, no-console*/ -import _, { compose, pipe, curry, filter, find, repeat, zipWith } from "ramda"; +import { describe, it } from 'flow-typed-test'; +import _, { + compose, + curry, + filter, + find, + pipe, + repeat, + values, + zipWith, +} from "ramda"; const ns: Array = [1, 2, 3, 4, 5]; const ss: Array = ["one", "two", "three", "four"]; @@ -151,17 +161,17 @@ const inverted1: { [k: string]: string } = _.invertObj(raceResultsByFirstName); const ks: Array = _.keys(raceResultsByFirstName); const ksi: Array = _.keysIn(square); -const values = { x: 1, y: 2, z: 3 }; +const xs = { x: 1, y: 2, z: 3 }; const prependKeyAndDouble = (num, key, obj) => key + num * 2; const obI: { [k: string]: string } = _.mapObjIndexed( prependKeyAndDouble, - values + xs ); //$ExpectError const obI2: { [k: string]: number } = _.mapObjIndexed( prependKeyAndDouble, - values + xs ); const ob1 = { a: 1 }; @@ -306,8 +316,16 @@ F.prototype.y = "Y"; const f = new F(); const topin = _.toPairsIn(f); -const val = _.values({ a: 1, b: 2, c: true }); -const val1: number | boolean = val[0]; +describe('values', () => { + it('provides a union per element when the types of all values vary', () => { + const val = values({ a: 1, b: 2, c: true }); + const val1: number | boolean = val[0]; + }) + + it('works with the example in the docs http://ramdajs.com/docs/#values', () => { + const vs: Array = values({a: 1, b: 2, c: 3}) + }) +}) const pred = _.where({ a: (a: string) => a === "foo", From 3f94f8086c5be4f2ed496d14e93b19f08fdb5e25 Mon Sep 17 00:00:00 2001 From: tyger Date: Mon, 19 Mar 2018 13:55:34 +0000 Subject: [PATCH 29/75] Adding optional message parameter to most functions of expect of Chai (#1974) * Adding optional message parameter to most functions of except * Add --- .../chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js b/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js index 23d6ea4227..ed2930b545 100644 --- a/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js +++ b/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js @@ -19,41 +19,42 @@ declare module "chai" { any: ExpectChain, all: ExpectChain, - a: ExpectChain & ((type: string) => ExpectChain), - an: ExpectChain & ((type: string) => ExpectChain), - - include: ExpectChain & ((value: mixed) => ExpectChain), - includes: ExpectChain & ((value: mixed) => ExpectChain), - contain: ExpectChain & ((value: mixed) => ExpectChain), - contains: ExpectChain & ((value: mixed) => ExpectChain), - - eq: (value: T) => ExpectChain, - eql: (value: T) => ExpectChain, - equal: (value: T) => ExpectChain, - equals: (value: T) => ExpectChain, - - above: (value: T & number) => ExpectChain, - gt: (value: T & number) => ExpectChain, - greaterThan: (value: T & number) => ExpectChain, - least: (value: T & number) => ExpectChain, - below: (value: T & number) => ExpectChain, - lessThan: (value: T & number) => ExpectChain, - lt: (value: T & number) => ExpectChain, - most: (value: T & number) => ExpectChain, - within: (start: T & number, finish: T & number) => ExpectChain, - - instanceof: (constructor: mixed) => ExpectChain, + a: ExpectChain & ((type: string, message?: string) => ExpectChain), + an: ExpectChain & ((type: string, message?: string) => ExpectChain), + + include: ExpectChain & ((value: mixed, message?: string) => ExpectChain), + includes: ExpectChain & ((value: mixed, message?: string) => ExpectChain), + contain: ExpectChain & ((value: mixed, message?: string) => ExpectChain), + contains: ExpectChain & ((value: mixed, message?: string) => ExpectChain), + + eq: (value: T, message?: string) => ExpectChain, + eql: (value: T, message?: string) => ExpectChain, + equal: (value: T, message?: string) => ExpectChain, + equals: (value: T, message?: string) => ExpectChain, + + above: (value: T & number, message?: string) => ExpectChain, + gt: (value: T & number, message?: string) => ExpectChain, + greaterThan: (value: T & number, message?: string) => ExpectChain, + least: (value: T & number, message?: string) => ExpectChain, + below: (value: T & number, message?: string) => ExpectChain, + lessThan: (value: T & number, message?: string) => ExpectChain, + lt: (value: T & number, message?: string) => ExpectChain, + most: (value: T & number, message?: string) => ExpectChain, + within: (start: T & number, finish: T & number, message?: string) => ExpectChain, + + instanceof: (constructor: mixed, message?: string) => ExpectChain, nested: ExpectChain, property:

( name: string, - value?: P + value?: P, + message?: string ) => ExpectChain

& ((name: string) => ExpectChain), - length: (value: number) => ExpectChain | ExpectChain, - lengthOf: (value: number) => ExpectChain, + length: (value: number, message?: string) => ExpectChain | ExpectChain, + lengthOf: (value: number, message?: string) => ExpectChain, - match: (regex: RegExp) => ExpectChain, - string: (string: string) => ExpectChain, + match: (regex: RegExp, message?: string) => ExpectChain, + string: (string: string, message?: string) => ExpectChain, key: (key: string) => ExpectChain, keys: ( @@ -67,19 +68,21 @@ declare module "chai" { msg?: string ) => ExpectChain, - respondTo: (method: string) => ExpectChain, + respondTo: (method: string, message?: string) => ExpectChain, itself: ExpectChain, - satisfy: (method: (value: T) => boolean) => ExpectChain, + satisfy: (method: (value: T) => boolean, message?: string) => ExpectChain, - closeTo: (expected: T & number, delta: number) => ExpectChain, + closeTo: (expected: T & number, delta: number, message?: string) => ExpectChain, - members: (set: mixed) => ExpectChain, - oneOf: (list: Array) => ExpectChain, + members: (set: mixed, message?: string) => ExpectChain, + oneOf: (list: Array, message?: string) => ExpectChain, - change: (obj: mixed, key: string) => ExpectChain, - increase: (obj: mixed, key: string) => ExpectChain, - decrease: (obj: mixed, key: string) => ExpectChain, + change: (obj: mixed, key: string, message?: string) => ExpectChain, + increase: (obj: mixed, key: string, message?: string) => ExpectChain, + decrease: (obj: mixed, key: string, message?: string) => ExpectChain, + + by: (delta: number, message?: string) => ExpectChain, // dirty-chai ok: () => ExpectChain, From a5452d3be36ca3aa0af89635d83b8840b9ce9f02 Mon Sep 17 00:00:00 2001 From: Nikodim Lazarov Date: Mon, 19 Mar 2018 16:55:27 +0200 Subject: [PATCH 30/75] Add 'className' and 'text' check definitions (#1979) Add 'className' and 'text' assertions for chai-enzyme --- definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js b/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js index ed2930b545..df9ca36d47 100644 --- a/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js +++ b/definitions/npm/chai_v4.x.x/flow_v0.25.0-/chai_v4.x.x.js @@ -136,7 +136,9 @@ declare module "chai" { data: (key: string, val?: any) => ExpectChain, prop: (key: string, val?: any) => ExpectChain, state: (key: string, val?: any) => ExpectChain, - value: (val: string) => ExpectChain + value: (val: string) => ExpectChain, + className: (val: string) => ExpectChain, + text: (val: string) => ExpectChain }; declare function expect(actual: T, message?: string): ExpectChain; From 3d998a60035cdaa08629e4f6eaad2c620dc124f6 Mon Sep 17 00:00:00 2001 From: Jeremy Tice Date: Mon, 19 Mar 2018 12:12:01 -0400 Subject: [PATCH 31/75] Add typing for return type of underscore's _.times (#1969) --- .../flow_v0.38.x-v0.49.x/test_underscore.js | 5 +++++ .../flow_v0.38.x-v0.49.x/underscore_v1.x.x.js | 2 +- .../underscore_v1.x.x/flow_v0.50.x-/test_underscore.js | 9 +++++++-- .../underscore_v1.x.x/flow_v0.50.x-/underscore_v1.x.x.js | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/test_underscore.js b/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/test_underscore.js index 4892b8ffc2..0bea26c20c 100644 --- a/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/test_underscore.js +++ b/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/test_underscore.js @@ -83,6 +83,11 @@ var identityIsString: string = _.identity('foo'); // $ExpectError var identityIsNotString: string = _.identity(42); +var timesString: Array = _.times(3, (i) => `str${i}`); +var timesNumber: Array = _.times(3, (i) => i + 1); +// $ExpectError +var timesNumberError: Array = _.times(3, (i) => i + 1); + var toArrayString: Array = _.toArray({foo: 'bar', baz: 'qux'}); var toArrayNumber: Array = _.toArray({foo: 4, bar: 2}); // $ExpectError diff --git a/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/underscore_v1.x.x.js b/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/underscore_v1.x.x.js index 99783033e7..9106c13d5c 100644 --- a/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/underscore_v1.x.x.js +++ b/definitions/npm/underscore_v1.x.x/flow_v0.38.x-v0.49.x/underscore_v1.x.x.js @@ -582,7 +582,7 @@ declare module "underscore" { identity(value: U): U; constant(value: U): () => U; noop(): void; - times(n: number, iteratee: Function, context?: mixed): void; + times(n: number, iteratee: (index: number) => T, context?: mixed): Array; random(min: number, max: number): number; // TODO: Is this right? mixin(object: Object): Underscore & Object; diff --git a/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/test_underscore.js b/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/test_underscore.js index ad55533975..1e6e9348e6 100644 --- a/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/test_underscore.js +++ b/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/test_underscore.js @@ -85,8 +85,8 @@ _.union([1, 2, 3], [2, 30, 1], [1, 40, [1]]); _.union([1, 2, 3], 4) _.filter([1, 2, 3, 4, 5, 6], function(num: number): boolean { return num % 2 === 0; }); -_.filter([1, 2, 3, 4, 5, 6], function(num, index: number, as: number[]): boolean { - return num % 2 == 0 || index === 7 || as.length > 3; +_.filter([1, 2, 3, 4, 5, 6], function(num, index: number, as: number[]): boolean { + return num % 2 == 0 || index === 7 || as.length > 3; }); _.filter({name: 'foo', a: 'bar'}, function (val, key, obj): boolean { var testKey = key + 'foo'; @@ -119,6 +119,11 @@ var identityIsString: string = _.identity('foo'); // $ExpectError var identityIsNotString: string = _.identity(42); +var timesString: Array = _.times(3, (i) => `str${i}`); +var timesNumber: Array = _.times(3, (i) => i + 1); +// $ExpectError +var timesNumberError: Array = _.times(3, (i) => i + 1); + var toArrayString: Array = _.toArray({foo: 'bar', baz: 'qux'}); var toArrayNumber: Array = _.toArray({foo: 4, bar: 2}); // $ExpectError diff --git a/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/underscore_v1.x.x.js b/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/underscore_v1.x.x.js index 8589d7327b..3081a98827 100644 --- a/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/underscore_v1.x.x.js +++ b/definitions/npm/underscore_v1.x.x/flow_v0.50.x-/underscore_v1.x.x.js @@ -584,7 +584,7 @@ declare module "underscore" { identity(value: U): U; constant(value: U): () => U; noop(): void; - times(n: number, iteratee: Function, context?: mixed): void; + times(n: number, iteratee: (index: number) => T, context?: mixed): Array; random(min: number, max: number): number; // TODO: Is this right? mixin(object: Object): Underscore & Object; @@ -612,7 +612,7 @@ declare module "underscore" { reduceRight(iteratee: (memo: U, value: T, index?: number) => U, init: U): U; find(predicate: (value: T) => boolean): ?T; filter(predicate: (value: T) => boolean): Array; - filter(predicate: {[string]: T}): Array; + filter(predicate: {[string]: T}): Array; where(properties: Object): Array; findWhere(properties: $Shape): ?T; reject(predicate: (value: T) => boolean, context?: mixed): Array; From b14f68e407c3c0365f00bc9cf42f954b124012cb Mon Sep 17 00:00:00 2001 From: Luke Page Date: Mon, 19 Mar 2018 17:30:39 +0100 Subject: [PATCH 32/75] Allow a .exe extension so binaries are not deleted on windows before running tests (#1977) --- cli/src/commands/runTests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/commands/runTests.js b/cli/src/commands/runTests.js index eafcd4846c..24fb242682 100644 --- a/cli/src/commands/runTests.js +++ b/cli/src/commands/runTests.js @@ -266,7 +266,7 @@ async function getOrderedFlowBinVersions( return _flowBinVersionPromise; } -const flowNameRegex = /^flow-v[0-9]+.[0-9]+.[0-9]+$/; +const flowNameRegex = /^flow-v[0-9]+.[0-9]+.[0-9]+(\.exe)?$/; /** * flow filename should be `flow-vx.x.x` * @param {string} name From 06bf92f21a3a67b10d2d25fdc67a3035b379588f Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Tue, 20 Mar 2018 20:18:10 -0700 Subject: [PATCH 33/75] Jest: Add alias for runTimersToTime as advanceTimersByTime (#1981) --- cli/flow-typed/npm/jest_v22.x.x.js | 7 +++++++ .../npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js | 3 +++ 2 files changed, 10 insertions(+) diff --git a/cli/flow-typed/npm/jest_v22.x.x.js b/cli/flow-typed/npm/jest_v22.x.x.js index 93673eb440..8d1c4aaa14 100644 --- a/cli/flow-typed/npm/jest_v22.x.x.js +++ b/cli/flow-typed/npm/jest_v22.x.x.js @@ -391,6 +391,13 @@ type JestObjectType = { * Executes only the macro task queue (i.e. all tasks queued by setTimeout() * or setInterval() and setImmediate()). */ + advanceTimersByTime(msToRun: number): void, + /** + * Executes only the macro task queue (i.e. all tasks queued by setTimeout() + * or setInterval() and setImmediate()). + * + * Renamed to `advanceTimersByTime`. + */ runTimersToTime(msToRun: number): void, /** * Executes only the macro-tasks that are currently pending (i.e., only the diff --git a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js index eadb5923c8..19e4e491b0 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js @@ -185,6 +185,9 @@ jest.spyOn({}, "foo"); jest.setTimeout(1000); +jest.runTimersToTime(3000); +jest.advanceTimersByTime(3000); + expect.addSnapshotSerializer(JSON.stringify); expect.assertions(1); expect.hasAssertions(); From 41bf7b055ed7cf86212ca50e1aad27e0985f492f Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 20 Mar 2018 23:22:33 -0400 Subject: [PATCH 34/75] Update react-bootstrap libdef (#1972) * Update react-bootstrap libdef * Add Media component type * Add NavDropdown component type * Correct type for Button bsStyle prop * Correct type for Col (xs|sm|md|lg)Hidden props * Type props for Media, MediaBody, and MediaLeft --- .../flow_v0.53.x-/react-bootstrap_v0.32.x.js | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js b/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js index 0a7ddea2b7..58f565166d 100644 --- a/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js +++ b/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js @@ -35,7 +35,7 @@ declare module "react-bootstrap" { componentClass?: ElementType, href?: string, type?: 'button' | 'reset' | 'submit', - bsStyle?: BsStyle, + bsStyle?: 'default' | 'primary' | 'success' | 'info' | 'warning' | 'danger' | 'link', bsSize?: BsStyle, bsClass?: string, }> {} @@ -278,6 +278,24 @@ declare module "react-bootstrap" { bsClass?: string }> {} + + declare class MediaBody extends React$Component<{ + align?: 'top' | 'middle' | 'bottom', + componentClass?: ElementType, + bsClass?: string + }> {} + declare class MediaLeft extends React$Component<{ + align?: 'top' | 'middle' | 'bottom', + bsClass?: string + }> {} + declare export class Media extends React$Component<{ + componentClass?: ElementType, + bsClass?: string + }> { + static Body: Class; + static Left: Class; + } + declare class Dialog extends React$Component<{ dialogClassName?: string, bsSize?: BsSize, @@ -342,6 +360,8 @@ declare module "react-bootstrap" { bsClass?: string }> {} + declare export class NavDropdown extends React$Component<{}> {} + declare export class NavItem extends React$Component<{ active?: boolean, disabled?: boolean, @@ -662,10 +682,10 @@ declare module "react-bootstrap" { sm?: number, md?: number, lg?: number, - xsHidden?: number, - smHidden?: number, - mdHidden?: number, - lgHidden?: number, + xsHidden?: boolean, + smHidden?: boolean, + mdHidden?: boolean, + lgHidden?: boolean, xsOffset?: number, smOffset?: number, mdOffset?: number, From 3476bfe6b8b99bab5b79198cd8441004443bb9d7 Mon Sep 17 00:00:00 2001 From: Peter Leonov Date: Wed, 21 Mar 2018 13:03:31 +0100 Subject: [PATCH 35/75] Add types for Introscope v1.0.6 (#1982) * Add introscope types * Add introscope tests * Make types better and fix tests (hopefully) * Set flow minimal version and update package version --- .../flow_v0.52.x-/introscope_v1.0.10.js | 10 ++++++++ .../npm/introscope_v1.0.10/test_introscope.js | 14 +++++++++++ .../npm/introscope_v1.0.10/test_scope.js | 23 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 definitions/npm/introscope_v1.0.10/flow_v0.52.x-/introscope_v1.0.10.js create mode 100644 definitions/npm/introscope_v1.0.10/test_introscope.js create mode 100644 definitions/npm/introscope_v1.0.10/test_scope.js diff --git a/definitions/npm/introscope_v1.0.10/flow_v0.52.x-/introscope_v1.0.10.js b/definitions/npm/introscope_v1.0.10/flow_v0.52.x-/introscope_v1.0.10.js new file mode 100644 index 0000000000..2cad456578 --- /dev/null +++ b/definitions/npm/introscope_v1.0.10/flow_v0.52.x-/introscope_v1.0.10.js @@ -0,0 +1,10 @@ +declare module 'introscope' { + // `introscope` is using any type on purpose, + // some developers require only part of their tests + // to have strict types. + // eslint-disable-next-line flowtype/no-weak-types + declare type AnyScope = { [string]: any }; + declare function introscope(scope: AnyScope): AnyScope => AnyScope; + + declare function scope(scope: Scope): ($Shape) => Scope; +} diff --git a/definitions/npm/introscope_v1.0.10/test_introscope.js b/definitions/npm/introscope_v1.0.10/test_introscope.js new file mode 100644 index 0000000000..9aa72d5431 --- /dev/null +++ b/definitions/npm/introscope_v1.0.10/test_introscope.js @@ -0,0 +1,14 @@ +import { introscope } from 'introscope'; + +// $ExpectError only objects allowed +introscope([]) + +const anyScope = introscope({ + existingProperty: 123 +})({}); + +// it's an ugly any, on purpose :) +(anyScope.existingProperty: number); +(anyScope.existingProperty: boolean); +(anyScope.nonExistingProp1: string); +(anyScope.nonExistingProp2: number); diff --git a/definitions/npm/introscope_v1.0.10/test_scope.js b/definitions/npm/introscope_v1.0.10/test_scope.js new file mode 100644 index 0000000000..9cf98fbca5 --- /dev/null +++ b/definitions/npm/introscope_v1.0.10/test_scope.js @@ -0,0 +1,23 @@ +import { scope } from 'introscope'; + +// $ExpectError only objects allowed +scope([]) +const objectScope = scope({}) +// $ExpectError only objects allowed +objectScope([]) + + +const strictScope = scope({ + numberProperty: 123, + stringProperty: 'flow' +})({ + numberProperty: 5 +}); + +(strictScope.numberProperty: number); +(strictScope.stringProperty: string); +// $ExpectError +(strictScope.nonExisting: boolean); + +// $ExpectError +strictScope.newProperty = true From d7bb878ca3a74ca96013d4afb69b9f7f74c22827 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Wed, 21 Mar 2018 13:53:14 -0400 Subject: [PATCH 36/75] Require specifying <*> for generics (#1984) --- .../flow_v0.47.x-/testcafe_v0.x.x.js | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/definitions/npm/testcafe_v0.x.x/flow_v0.47.x-/testcafe_v0.x.x.js b/definitions/npm/testcafe_v0.x.x/flow_v0.47.x-/testcafe_v0.x.x.js index 8dcf655ef7..aa93e80541 100644 --- a/definitions/npm/testcafe_v0.x.x/flow_v0.47.x-/testcafe_v0.x.x.js +++ b/definitions/npm/testcafe_v0.x.x/flow_v0.47.x-/testcafe_v0.x.x.js @@ -199,11 +199,11 @@ declare interface TestCafe$SelectorPromise extends TestCafe$SelectorAPI, Promise } -declare interface TestCafe$CustomMethodsSelectorPromiseI extends TestCafe$SelectorAPI, Promise> { +declare interface TestCafe$CustomMethodsSelectorPromiseI extends TestCafe$SelectorAPI, Promise> { } -declare type TestCafe$CustomMethodsSelectorPromise = TestCafe$CustomMethodsSelectorPromiseI & $ObjMap; +declare type TestCafe$CustomMethodsSelectorPromise = TestCafe$CustomMethodsSelectorPromiseI & $ObjMap; declare interface TestCafe$CustomPropsSelectorPromiseI extends TestCafe$SelectorAPI, Promise> { @@ -260,7 +260,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), options?: TestCafe$ClickActionOptions): TestCafe$TestControllerPromise, rightClick( @@ -268,7 +268,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), options?: TestCafe$ClickActionOptions): TestCafe$TestControllerPromise, doubleClick( @@ -276,7 +276,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), options?: TestCafe$ClickActionOptions): TestCafe$TestControllerPromise, hover( @@ -284,7 +284,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), options?: TestCafe$MouseActionOptions): TestCafe$TestControllerPromise, drag( @@ -292,7 +292,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), dragOffsetX: number, dragOffsetY: number, options?: TestCafe$MouseActionOptions): TestCafe$TestControllerPromise, @@ -302,12 +302,12 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), destinationSelector: string | TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), options?: TestCafe$MouseActionOptions): TestCafe$TestControllerPromise, typeText( @@ -315,7 +315,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), text: string, options?: TypeActionOptions): TestCafe$TestControllerPromise, @@ -324,7 +324,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), startPos: number, endPos: number, options?: TestCafe$ActionOptions): TestCafe$TestControllerPromise, @@ -334,7 +334,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), startLine: number, startPos: number, endLine: number, @@ -346,12 +346,12 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), endSelector: string | TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), options?: TestCafe$ActionOptions): TestCafe$TestControllerPromise, pressKey(keys: string, options?: TestCafe$ActionOptions): TestCafe$TestControllerPromise, @@ -365,7 +365,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection), + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>), filePath: string | string[]): TestCafe$TestControllerPromise, clearUpload( @@ -373,7 +373,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)): TestCafe$TestControllerPromise, + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>)): TestCafe$TestControllerPromise, takeScreenshot(path?: string): TestCafe$TestControllerPromise, @@ -388,7 +388,7 @@ declare interface TestCafe$TestController { TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise | - ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)): TestCafe$TestControllerPromise, + ((...args: any[]) => Node | Node[] | NodeList<*> | HTMLCollection<*>)): TestCafe$TestControllerPromise, switchToMainWindow(): TestCafe$TestControllerPromise, @@ -396,7 +396,7 @@ declare interface TestCafe$TestController { setNativeDialogHandler( fn: (( - type: alert | confirm | beforeunload | prompt, + type: 'alert' | 'confirm' | 'beforeunload' | 'prompt', text: string, url: string) => any) | null, options?: TestCafe$ClientFunctionOptions): TestCafe$TestControllerPromise, @@ -582,7 +582,7 @@ declare interface TestCafe$CustomSelectorFnI extends TestCafe$SelectorAPI, Te declare type TestCafe$CustomPropsSelectorFn = TestCafe$CustomSelectorFnI> & $ObjMap; -declare type TestCafe$CustomMethodsSelectorFn = TestCafe$CustomSelectorFnI> & $ObjMap; +declare type TestCafe$CustomMethodsSelectorFn = TestCafe$CustomSelectorFnI> & $ObjMap; declare interface TestCafe$ClientFunctionFn { (...args: any[]): Promise, @@ -643,7 +643,7 @@ declare module 'testcafe' { declare module.exports: { (hostname: string, port1: number, port2: number): Promise, - Selector(init: string | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection) | TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise, + Selector(init: string | ((...args: any[]) => null | Node | Node[] | NodeList<*> | HTMLCollection<*>) | TestCafe$SelectorFn | TestCafe$NodeSnapshot | TestCafe$SelectorPromise, options?: TestCafe$SelectorOptions): TestCafe$SelectorFn, ClientFunction(fn: Function, options?: TestCafe$ClientFunctionOptions): TestCafe$ClientFunctionFn, @@ -651,4 +651,3 @@ declare module 'testcafe' { t: TestCafe$TestController }; } - From acdc1ea56fcffc067558f5aee202b252e5fa253c Mon Sep 17 00:00:00 2001 From: Ville Saukkonen Date: Thu, 22 Mar 2018 00:30:15 +0200 Subject: [PATCH 37/75] overlayTrigger trigger prop takes array of triggers, not any strings (#1983) --- .../flow_v0.53.x-/react-bootstrap_v0.32.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js b/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js index 58f565166d..3cfba03c43 100644 --- a/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js +++ b/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js @@ -600,7 +600,7 @@ declare module "react-bootstrap" { }> {} declare export class OverlayTrigger extends React$Component<{ - trigger?: TriggerType | Array, + trigger?: TriggerType | Array, delay?: number, delayShow?: number, delayHide?: number, From a33adf993162d655d6822b2ec9c37da73edd7e3c Mon Sep 17 00:00:00 2001 From: Ville Saukkonen Date: Thu, 22 Mar 2018 01:07:20 +0200 Subject: [PATCH 38/75] proper support for toString in redux-actions (#1985) --- .../flow_v0.39.x-/redux-actions_v2.x.x.js | 14 ++++++------- .../flow_v0.39.x-/test_createAction.js | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js b/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js index 87ae8ad19f..493678c943 100644 --- a/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js +++ b/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js @@ -26,28 +26,28 @@ declare module "redux-actions" { declare function createAction( type: T, $?: empty // hack to force Flow to not use this signature when more than one argument is given - ): (payload: P, ...rest: any[]) => { type: T, payload: P, error?: boolean }; + ): {(payload: P, ...rest: any[]): { type: T, payload: P, error?: boolean }, toString: () => T}; declare function createAction( type: T, payloadCreator: (...rest: A) => P, $?: empty - ): (...rest: A) => { type: T, payload: P, error?: boolean }; + ): {(...rest: A): { type: T, payload: P, error?: boolean }, toString: () => T}; declare function createAction( type: T, payloadCreator: (...rest: A) => P, metaCreator: (...rest: A) => M - ): (...rest: A) => { type: T, payload: P, error?: boolean, meta: M }; + ): {(...rest: A): { type: T, payload: P, error?: boolean, meta: M }, toString: () => T}; declare function createAction( type: T, payloadCreator: null | void, metaCreator: (payload: P, ...rest: any[]) => M - ): ( - payload: P, - ...rest: any[] - ) => { type: T, payload: P, error?: boolean, meta: M }; + ): {( + payload: P, + ...rest: any[] + ): { type: T, payload: P, error?: boolean, meta: M }, toString: () => T}; // `createActions` is quite difficult to write a type for. Maybe try not to // use this one? diff --git a/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/test_createAction.js b/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/test_createAction.js index 1c8b5ed1eb..234fb282e6 100644 --- a/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/test_createAction.js +++ b/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/test_createAction.js @@ -25,6 +25,10 @@ function test_createAction() { // $ExpectError assert(a.payload, (x: number) => {}); } + + (action.toString(): 'INCREMENT'); + // $ExpectError wrong type + (action.toString(): 'DECREMENT'); } function test_createAction_givenPayloadType() { @@ -46,6 +50,10 @@ function test_createAction_givenPayloadType() { // $ExpectError assert(a2.meta, (x: string) => {}); + + (action.toString(): 'INCREMENT'); + // $ExpectError wrong type + (action.toString(): 'DECREMENT'); } function test_createAction_withPayloadCreator() { @@ -68,6 +76,10 @@ function test_createAction_withPayloadCreator() { // $ExpectError assert(a.payload, (x: string) => {}); + + (action.toString(): 'INCREMENT'); + // $ExpectError wrong type + (action.toString(): 'DECREMENT'); } function test_createAction_withPayloadCreatorAndMeta() { @@ -78,6 +90,10 @@ function test_createAction_withPayloadCreatorAndMeta() { // $ExpectError assert(a.meta, (x: string) => {}); + + (action.toString(): 'INCREMENT'); + // $ExpectError wrong type + (action.toString(): 'DECREMENT'); } function test_createAction_withMeta() { @@ -88,6 +104,10 @@ function test_createAction_withMeta() { // $ExpectError assert(a.meta, (x: string) => {}); + + (action.toString(): 'INCREMENT'); + // $ExpectError wrong type + (action.toString(): 'DECREMENT'); } // Helper to assert that the type of the first argument is compatible with the From 2be94be029624d9f22710059ac0c2c2d23ea66e2 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 21 Mar 2018 18:07:52 -0500 Subject: [PATCH 39/75] fix(Attribute): add missing allowNull property (#1988) --- .../npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js b/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js index 91fcd26e45..a84cefab97 100644 --- a/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js +++ b/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js @@ -1338,6 +1338,8 @@ declare module "sequelize" { * A string or a data type */ type: DataTypeAbstract, + + allowNull?: boolean, values?: Array, From c5ceb2767a7f4abd57e6b6d52500834c605bf671 Mon Sep 17 00:00:00 2001 From: Ville Saukkonen Date: Thu, 22 Mar 2018 04:51:31 +0200 Subject: [PATCH 40/75] Look package version from package.json if not provided (#1989) --- cli/src/commands/__tests__/install-test.js | 10 ++++++++- cli/src/commands/install.js | 24 ++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/cli/src/commands/__tests__/install-test.js b/cli/src/commands/__tests__/install-test.js index 6740a2a495..94e000404d 100644 --- a/cli/src/commands/__tests__/install-test.js +++ b/cli/src/commands/__tests__/install-test.js @@ -103,6 +103,7 @@ describe('install (command)', () => { describe('installNpmLibDefs', () => { const origConsoleError = console.error; + beforeEach(() => { (console: any).error = jest.fn(); }); @@ -140,6 +141,12 @@ describe('install (command)', () => { () => { return testProject(async ROOT_DIR => { await touchFile(path.join(ROOT_DIR, '.flowconfig')); + await writePkgJson(path.join(ROOT_DIR, 'package.json'), { + name: 'test', + devDependencies: { + 'flow-bin': '^0.40.0', + }, + }); const result = await installNpmLibDefs({ cwd: ROOT_DIR, flowVersion: parseFlowDirString('flow_v0.40.0', 'testContext'), @@ -153,7 +160,8 @@ describe('install (command)', () => { expect(result).toBe(1); expect(_mock(console.error).mock.calls).toEqual([ [ - 'ERROR: Please specify npm package names in the format of `foo@1.2.3`', + 'ERROR: Package not found from package.json.\n' + + 'Please specify version for the package in the format of `foo@1.2.3`', ], ]); }); diff --git a/cli/src/commands/install.js b/cli/src/commands/install.js index fcdcf58cd0..fe3c18b97c 100644 --- a/cli/src/commands/install.js +++ b/cli/src/commands/install.js @@ -190,15 +190,23 @@ async function installNpmLibDefs({ const term = explicitLibDefs[i]; const termMatches = term.match(/(@[^@\/]+\/)?([^@]+)@(.+)/); if (termMatches == null) { - console.error( - 'ERROR: Please specify npm package names in the format of `foo@1.2.3`', - ); - return 1; + const pkgJsonData = await getPackageJsonData(cwd); + const pkgJsonDeps = getPackageJsonDependencies(pkgJsonData, []); + const packageVersion = pkgJsonDeps[term]; + if (packageVersion) { + libdefsToSearchFor.set(term, packageVersion); + } else { + console.error( + 'ERROR: Package not found from package.json.\n' + + 'Please specify version for the package in the format of `foo@1.2.3`', + ); + return 1; + } + } else { + const [_, npmScope, pkgName, pkgVerStr] = termMatches; + const scopedPkgName = npmScope != null ? npmScope + pkgName : pkgName; + libdefsToSearchFor.set(scopedPkgName, pkgVerStr); } - - const [_, npmScope, pkgName, pkgVerStr] = termMatches; - const scopedPkgName = npmScope != null ? npmScope + pkgName : pkgName; - libdefsToSearchFor.set(scopedPkgName, pkgVerStr); } console.log(`• Searching for ${libdefsToSearchFor.size} libdefs...`); } else { From 1ae5dd96732f103cd447f1b7469c4999b85c5c84 Mon Sep 17 00:00:00 2001 From: Ville Saukkonen Date: Sat, 24 Mar 2018 04:59:22 +0200 Subject: [PATCH 41/75] redux-connect toString is read-only (#1995) --- .../flow_v0.39.x-/redux-actions_v2.x.x.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js b/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js index 493678c943..ded2f89017 100644 --- a/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js +++ b/definitions/npm/redux-actions_v2.x.x/flow_v0.39.x-/redux-actions_v2.x.x.js @@ -26,19 +26,19 @@ declare module "redux-actions" { declare function createAction( type: T, $?: empty // hack to force Flow to not use this signature when more than one argument is given - ): {(payload: P, ...rest: any[]): { type: T, payload: P, error?: boolean }, toString: () => T}; + ): {(payload: P, ...rest: any[]): { type: T, payload: P, error?: boolean }, +toString: () => T}; declare function createAction( type: T, payloadCreator: (...rest: A) => P, $?: empty - ): {(...rest: A): { type: T, payload: P, error?: boolean }, toString: () => T}; + ): {(...rest: A): { type: T, payload: P, error?: boolean }, +toString: () => T}; declare function createAction( type: T, payloadCreator: (...rest: A) => P, metaCreator: (...rest: A) => M - ): {(...rest: A): { type: T, payload: P, error?: boolean, meta: M }, toString: () => T}; + ): {(...rest: A): { type: T, payload: P, error?: boolean, meta: M }, +toString: () => T}; declare function createAction( type: T, @@ -47,7 +47,7 @@ declare module "redux-actions" { ): {( payload: P, ...rest: any[] - ): { type: T, payload: P, error?: boolean, meta: M }, toString: () => T}; + ): { type: T, payload: P, error?: boolean, meta: M }, +toString: () => T}; // `createActions` is quite difficult to write a type for. Maybe try not to // use this one? From 71eabacc678b58b402a2f0f85a28fa5677e40b8f Mon Sep 17 00:00:00 2001 From: Luke Albao Date: Tue, 27 Mar 2018 13:33:51 -0400 Subject: [PATCH 42/75] Fix `return` typo in CONTRIBUTING.md (#2003) --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c595fa574..cd6ee22de1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,7 +122,7 @@ function setCache(key: string, value: any) { cache.set(key, value); } function getCache(key: string) { - cache.get(key); + return cache.get(key); } setCache('foo', 42); @@ -140,7 +140,7 @@ function setCache(key: string, value: mixed) { cache.set(key, value); } function getCache(key: string) { - cache.get(key); + return cache.get(key); } setCache('foo', 42); From 0215e23590400fe8a4802efc6f3763447192277d Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 27 Mar 2018 13:43:35 -0400 Subject: [PATCH 43/75] Fix Jest libdef to include new method #advanceTimersByTime. (#2004) --- .../npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js | 7 +++++++ definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js index 76abd0e5dc..f0a635624e 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js @@ -388,6 +388,13 @@ type JestObjectType = { * Executes only the macro task queue (i.e. all tasks queued by setTimeout() * or setInterval() and setImmediate()). */ + advanceTimersByTime(msToRun: number): void, + /** + * Executes only the macro task queue (i.e. all tasks queued by setTimeout() + * or setInterval() and setImmediate()). + * + * Renamed to `advanceTimersByTime`. + */ runTimersToTime(msToRun: number): void, /** * Executes only the macro-tasks that are currently pending (i.e., only the diff --git a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js index 393b9b9c81..7fc5476fe4 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js @@ -396,6 +396,13 @@ type JestObjectType = { * Executes only the macro task queue (i.e. all tasks queued by setTimeout() * or setInterval() and setImmediate()). */ + advanceTimersByTime(msToRun: number): void, + /** + * Executes only the macro task queue (i.e. all tasks queued by setTimeout() + * or setInterval() and setImmediate()). + * + * Renamed to `advanceTimersByTime`. + */ runTimersToTime(msToRun: number): void, /** * Executes only the macro-tasks that are currently pending (i.e., only the From e6922b81255b197836c5da2d3898a91d5dc6ccb2 Mon Sep 17 00:00:00 2001 From: Facundo Viale Date: Tue, 27 Mar 2018 14:49:15 -0300 Subject: [PATCH 44/75] Add deepmerge (#2000) --- .../flow_v0.57.3-/deepmerge_v2.1.x.js | 12 ++++++++++++ .../npm/deepmerge_v2.1.x/test_deepmerge_v2.1.x.js | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 definitions/npm/deepmerge_v2.1.x/flow_v0.57.3-/deepmerge_v2.1.x.js create mode 100644 definitions/npm/deepmerge_v2.1.x/test_deepmerge_v2.1.x.js diff --git a/definitions/npm/deepmerge_v2.1.x/flow_v0.57.3-/deepmerge_v2.1.x.js b/definitions/npm/deepmerge_v2.1.x/flow_v0.57.3-/deepmerge_v2.1.x.js new file mode 100644 index 0000000000..3d06b79d30 --- /dev/null +++ b/definitions/npm/deepmerge_v2.1.x/flow_v0.57.3-/deepmerge_v2.1.x.js @@ -0,0 +1,12 @@ +declare module 'deepmerge' { + declare type Options = { + clone?: boolean, + arrayMerge?: (destination: any[], source: any[], options?: Options) => Array + } + + declare module.exports: { + (a: A, b: B, options?: Options): A & B, + all(objects: Array<$Shape>, options?: Options): T + }; + +} diff --git a/definitions/npm/deepmerge_v2.1.x/test_deepmerge_v2.1.x.js b/definitions/npm/deepmerge_v2.1.x/test_deepmerge_v2.1.x.js new file mode 100644 index 0000000000..2910990776 --- /dev/null +++ b/definitions/npm/deepmerge_v2.1.x/test_deepmerge_v2.1.x.js @@ -0,0 +1,8 @@ +const deepmerge = require("deepmerge"); + +const m1: { a: string, b: string } = deepmerge({a: ''}, { b: '' }) + +const m2: { a: string, b: string } = deepmerge.all([ {a: ''}, { b: '' } ]) + +// $ExpectError +const m3: { a: number, b: string } = deepmerge({a: ''}, { b: '' }) From e278878fb6e954b054f5a735071b79694eeb06de Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Tue, 27 Mar 2018 17:03:45 -0500 Subject: [PATCH 45/75] fix(sequelize): correct QueryInterface.addIndex arguments (#2002) See http://docs.sequelizejs.com/class/lib/query-interface.js~QueryInterface.html#instance-method-addIndex * fix(sequelize): correct QueryInterface.addIndex arguments * Update test_sequelize.js --- .../flow_v0.42.x-/sequelize_v4.x.x.js | 12 +++++++++--- .../sequelize_v4.x.x/flow_v0.42.x-/test_sequelize.js | 5 +---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js b/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js index a84cefab97..52b736e9e6 100644 --- a/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js +++ b/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/sequelize_v4.x.x.js @@ -4322,9 +4322,15 @@ declare module "sequelize" { */ addIndex( tableName: string | Object, - attributes: string[], - options?: DefineIndexOptions, - rawTablename?: string): Promise, + options?: { + fields: Array, + unique?: boolean, + using?: string, + type?: IndexType, + name?: string, + where?: WhereOptions, + } + ): Promise, /** * Shows the index of a table diff --git a/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/test_sequelize.js b/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/test_sequelize.js index 5ceafb9663..98953999b5 100644 --- a/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/test_sequelize.js +++ b/definitions/npm/sequelize_v4.x.x/flow_v0.42.x-/test_sequelize.js @@ -1233,15 +1233,12 @@ queryInterface.createTable( 'table', { name : Sequelize.STRING }, { logging : fu queryInterface.createTable( 'skipme', { name : Sequelize.STRING } ); queryInterface.dropAllTables( { skip : ['skipme'] } ); queryInterface.dropTable( 'Group', { logging : function() { } } ); -queryInterface.addIndex( 'Group', ['username', 'isAdmin'], { logging : function() { } } ); +queryInterface.addIndex( 'Group', { fields: ['username', 'isAdmin'] } ); queryInterface.showIndex( 'Group', { logging : function() { } } ); queryInterface.removeIndex( 'Group', ['username', 'isAdmin'], { logging : function() { } } ); queryInterface.showIndex( 'Group' ); queryInterface.createTable( 'table', { name : { type : Sequelize.STRING } }, { schema : 'schema' } ); -queryInterface.addIndex( { schema : 'a', tableName : 'c' }, ['d', 'e'], { logging : function() {} }, 'schema_table' ); queryInterface.showIndex( { schema : 'schema', tableName : 'table' }, { logging : function() {} } ); -queryInterface.addIndex( 'Group', ['from'] ); -queryInterface.addIndex( 'Group', ['from'], { indexName: 'group_from' } ); queryInterface.describeTable( '_Users', { logging : function() {} } ); queryInterface.createTable( 's', { table_id : { type : Sequelize.INTEGER, primaryKey : true, autoIncrement : true } } ); queryInterface.createTable( 'SomeTable', { someEnum : Sequelize.ENUM( 'value1', 'value2', 'value3' ) } ); From 5af8bb59019b99f215d4b3226c6062ed5537337b Mon Sep 17 00:00:00 2001 From: mrm007 Date: Fri, 30 Mar 2018 01:03:43 +1100 Subject: [PATCH 46/75] Don't import React definitions globally in react-helmet (#2005) * Don't import React definitions globally in react-helmet * Use raw React types directly, without importing them --- .../flow_v0.53.x-/react-helmet_v5.x.x.js | 90 +++++++++---------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/definitions/npm/react-helmet_v5.x.x/flow_v0.53.x-/react-helmet_v5.x.x.js b/definitions/npm/react-helmet_v5.x.x/flow_v0.53.x-/react-helmet_v5.x.x.js index b4e961e040..e2ac0b684b 100644 --- a/definitions/npm/react-helmet_v5.x.x/flow_v0.53.x-/react-helmet_v5.x.x.js +++ b/definitions/npm/react-helmet_v5.x.x/flow_v0.53.x-/react-helmet_v5.x.x.js @@ -1,53 +1,51 @@ -import type { Node, Element } from 'react'; - declare module 'react-helmet' { - declare type Props = { - base?: Object, - bodyAttributes?: Object, - children?: Node, - defaultTitle?: string, - defer?: boolean, - encodeSpecialCharacters?: boolean, - htmlAttributes?: Object, - link?: Array, - meta?: Array, - noscript?: Array, - onChangeClientState?: ( - newState?: Object, - addedTags?: Object, - removeTags?: Object - ) => any, - script?: Array, - style?: Array, - title?: string, - titleAttributes?: Object, - titleTemplate?: string, - } + declare type Props = { + base?: Object, + bodyAttributes?: Object, + children?: React$Node, + defaultTitle?: string, + defer?: boolean, + encodeSpecialCharacters?: boolean, + htmlAttributes?: Object, + link?: Array, + meta?: Array, + noscript?: Array, + onChangeClientState?: ( + newState?: Object, + addedTags?: Object, + removeTags?: Object + ) => any, + script?: Array, + style?: Array, + title?: string, + titleAttributes?: Object, + titleTemplate?: string, + } - declare interface TagMethods { - toString(): string; - toComponent(): [Element<*>] | Element<*> | Array; - } + declare interface TagMethods { + toString(): string; + toComponent(): [React$Element<*>] | React$Element<*> | Array; + } - declare interface StateOnServer { - base: TagMethods; - bodyAttributes: TagMethods, - htmlAttributes: TagMethods; - link: TagMethods; - meta: TagMethods; - noscript: TagMethods; - script: TagMethods; - style: TagMethods; - title: TagMethods; - } + declare interface StateOnServer { + base: TagMethods; + bodyAttributes: TagMethods, + htmlAttributes: TagMethods; + link: TagMethods; + meta: TagMethods; + noscript: TagMethods; + script: TagMethods; + style: TagMethods; + title: TagMethods; + } - declare class Helmet extends React$Component { - static rewind(): StateOnServer; - static renderStatic(): StateOnServer; - static canUseDom(canUseDOM: boolean): void; - } + declare class Helmet extends React$Component { + static rewind(): StateOnServer; + static renderStatic(): StateOnServer; + static canUseDom(canUseDOM: boolean): void; + } - declare export default typeof Helmet - declare export var Helmet: typeof Helmet + declare export default typeof Helmet + declare export var Helmet: typeof Helmet } From 154fa81382c7d76776d3707033292f6d858a997d Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Thu, 29 Mar 2018 07:13:22 -0700 Subject: [PATCH 47/75] Add className prop to react-router-dom Link component (#2008) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://reacttraining.com/react-router/web/api/Link/others > You can also pass props you’d like to be on the such as a title, id, className, etc. --- .../flow_v0.53.x-/react-router-dom_v4.x.x.js | 1 + 1 file changed, 1 insertion(+) diff --git a/definitions/npm/react-router-dom_v4.x.x/flow_v0.53.x-/react-router-dom_v4.x.x.js b/definitions/npm/react-router-dom_v4.x.x/flow_v0.53.x-/react-router-dom_v4.x.x.js index de8ef973a0..c2caca5215 100644 --- a/definitions/npm/react-router-dom_v4.x.x/flow_v0.53.x-/react-router-dom_v4.x.x.js +++ b/definitions/npm/react-router-dom_v4.x.x/flow_v0.53.x-/react-router-dom_v4.x.x.js @@ -15,6 +15,7 @@ declare module "react-router-dom" { }> {} declare export class Link extends React$Component<{ + className?: string, to: string | LocationShape, replace?: boolean, children?: React$Node From 9dcc97865b3a43bf9f99e20f1a2ae29a11a8f624 Mon Sep 17 00:00:00 2001 From: Adam Bergman Date: Thu, 29 Mar 2018 18:58:04 +0200 Subject: [PATCH 48/75] Add response type to axios libdef (#2006) This PR adds a separate response type to axios calls, earlier the definitions used the same infered type for config.data and response.data. This has been mentioned in #1975 and #1539. But hopefully this wont break backwards compatability since I added the original type (T) as default for the new response type (R). Also verified by tests. As of now I have only updated the 0.18.x-version. But the same issue is present in earlier versions as well. If you think I should update the old ones as well I'd be happy to do so. * Add separate response type to axios THis commit adds a separate response type to axios calls, earlier the definitions used the same infered type for config.data and response.data. But hopefully this wont break backwards compatability since I added the original type (T) as default for the new response type (R). * Use AxiosPromise when testing types * Test that types carries through --- .../flow_v0.25.x-/axios_v0.18.x.js | 80 +++++++++---------- .../npm/axios_v0.18.x/test_axios_v0.18.x.js | 13 +++ 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/definitions/npm/axios_v0.18.x/flow_v0.25.x-/axios_v0.18.x.js b/definitions/npm/axios_v0.18.x/flow_v0.25.x-/axios_v0.18.x.js index 9737871fd9..63acb83483 100644 --- a/definitions/npm/axios_v0.18.x/flow_v0.25.x-/axios_v0.18.x.js +++ b/definitions/npm/axios_v0.18.x/flow_v0.25.x-/axios_v0.18.x.js @@ -28,8 +28,8 @@ declare module "axios" { reason?: Cancel; throwIfRequested(): void; } - declare interface AxiosXHRConfigBase { - adapter?: (config: AxiosXHRConfig) => Promise>; + declare interface AxiosXHRConfigBase { + adapter?: (config: AxiosXHRConfig) => Promise>; auth?: { username: string, password: string @@ -54,93 +54,93 @@ declare module "axios" { | "stream"; timeout?: number; transformRequest?: AxiosTransformer | Array>; - transformResponse?: AxiosTransformer | Array>; + transformResponse?: AxiosTransformer | Array>; validateStatus?: (status: number) => boolean; withCredentials?: boolean; xsrfCookieName?: string; xsrfHeaderName?: string; } - declare type $AxiosXHRConfigBase = AxiosXHRConfigBase; - declare interface AxiosXHRConfig extends AxiosXHRConfigBase { + declare type $AxiosXHRConfigBase = AxiosXHRConfigBase; + declare interface AxiosXHRConfig extends AxiosXHRConfigBase { data?: T; method?: string; url: string; } - declare type $AxiosXHRConfig = AxiosXHRConfig; - declare class AxiosXHR { - config: AxiosXHRConfig; - data: T; + declare type $AxiosXHRConfig = AxiosXHRConfig; + declare class AxiosXHR { + config: AxiosXHRConfig; + data: R; headers?: Object; status: number; statusText: string; request: http$ClientRequest | XMLHttpRequest; } - declare type $AxiosXHR = AxiosXHR; + declare type $AxiosXHR = AxiosXHR; declare type AxiosInterceptorIdent = number; - declare class AxiosRequestInterceptor { + declare class AxiosRequestInterceptor { use( successHandler: ?( - response: AxiosXHRConfig - ) => Promise> | AxiosXHRConfig<*>, + response: AxiosXHRConfig + ) => Promise> | AxiosXHRConfig<*,*>, errorHandler: ?(error: mixed) => mixed ): AxiosInterceptorIdent; eject(ident: AxiosInterceptorIdent): void; } - declare class AxiosResponseInterceptor { + declare class AxiosResponseInterceptor { use( - successHandler: ?(response: AxiosXHR) => mixed, + successHandler: ?(response: AxiosXHR) => mixed, errorHandler: ?(error: $AxiosError) => mixed ): AxiosInterceptorIdent; eject(ident: AxiosInterceptorIdent): void; } - declare type AxiosPromise = Promise>; + declare type AxiosPromise = Promise>; declare class Axios { - constructor(config?: AxiosXHRConfigBase): void; - $call: ( - config: AxiosXHRConfig | string, - config?: AxiosXHRConfig - ) => AxiosPromise; - request(config: AxiosXHRConfig): AxiosPromise; - delete(url: string, config?: AxiosXHRConfigBase): AxiosPromise; - get(url: string, config?: AxiosXHRConfigBase): AxiosPromise; - head(url: string, config?: AxiosXHRConfigBase): AxiosPromise; - post( + constructor(config?: AxiosXHRConfigBase): void; + $call: ( + config: AxiosXHRConfig | string, + config?: AxiosXHRConfig + ) => AxiosPromise; + request(config: AxiosXHRConfig): AxiosPromise; + delete(url: string, config?: AxiosXHRConfigBase): AxiosPromise; + get(url: string, config?: AxiosXHRConfigBase): AxiosPromise; + head(url: string, config?: AxiosXHRConfigBase): AxiosPromise; + post( url: string, data?: mixed, - config?: AxiosXHRConfigBase - ): AxiosPromise; - put( + config?: AxiosXHRConfigBase + ): AxiosPromise; + put( url: string, data?: mixed, - config?: AxiosXHRConfigBase - ): AxiosPromise; - patch( + config?: AxiosXHRConfigBase + ): AxiosPromise; + patch( url: string, data?: mixed, - config?: AxiosXHRConfigBase - ): AxiosPromise; + config?: AxiosXHRConfigBase + ): AxiosPromise; interceptors: { request: AxiosRequestInterceptor, response: AxiosResponseInterceptor }; - defaults: { headers: Object } & AxiosXHRConfig<*>; + defaults: { headers: Object } & AxiosXHRConfig<*,*>; } - declare class AxiosError extends Error { - config: AxiosXHRConfig; + declare class AxiosError extends Error { + config: AxiosXHRConfig; request?: http$ClientRequest | XMLHttpRequest; - response?: AxiosXHR; + response?: AxiosXHR; code?: string; } - declare type $AxiosError = AxiosError; + declare type $AxiosError = AxiosError; declare interface AxiosExport extends Axios { Axios: typeof Axios; Cancel: Class; CancelToken: Class; isCancel(value: any): boolean; - create(config?: AxiosXHRConfigBase): Axios; + create(config?: AxiosXHRConfigBase): Axios; all: typeof Promise.all; spread(callback: Function): (arr: Array) => Function; } diff --git a/definitions/npm/axios_v0.18.x/test_axios_v0.18.x.js b/definitions/npm/axios_v0.18.x/test_axios_v0.18.x.js index 1d2dc54f53..c043a40a5c 100644 --- a/definitions/npm/axios_v0.18.x/test_axios_v0.18.x.js +++ b/definitions/npm/axios_v0.18.x/test_axios_v0.18.x.js @@ -4,6 +4,7 @@ import type { $AxiosXHR, CancelTokenSource, Cancel, + AxiosPromise, } from 'axios'; (axios.get('foo'): Promise<*>); (axios.post('bar', {}, { @@ -86,3 +87,15 @@ axios.all([ // $ExpectError (a: string); }) + +const promise1: AxiosPromise<{ foo: string }, { bar: string }> = axios({ url: '/', method: 'post', data: { foo: 'bar' }}) +promise1.then(({ data }) => { + (data.bar: string); + // $ExpectError + data.foo; +}); + +const promise2: AxiosPromise<{ foo: number }> = axios({ url: '/', method: 'post', data: { foo: 1 }}) +promise2.then(({ data }) => { + data.foo + 1; +}); From a90ebf442a317536a993e6104c34fe589cfee843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Szak=C3=A1llas?= <5807322+dszakallas@users.noreply.github.com> Date: Mon, 2 Apr 2018 03:02:10 +0200 Subject: [PATCH 49/75] Adding libdef for eventemitter3_v3.x.x (#2014) * add eventemitter3_v3 * add ; * fix test --- .../flow_v0.25.x-/eventemitter3_v3.x.x.js | 26 ++++++++++ .../test_eventemitter3-v3.js | 47 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 definitions/npm/eventemitter3_v3.x.x/flow_v0.25.x-/eventemitter3_v3.x.x.js create mode 100644 definitions/npm/eventemitter3_v3.x.x/test_eventemitter3-v3.js diff --git a/definitions/npm/eventemitter3_v3.x.x/flow_v0.25.x-/eventemitter3_v3.x.x.js b/definitions/npm/eventemitter3_v3.x.x/flow_v0.25.x-/eventemitter3_v3.x.x.js new file mode 100644 index 0000000000..b8be149f67 --- /dev/null +++ b/definitions/npm/eventemitter3_v3.x.x/flow_v0.25.x-/eventemitter3_v3.x.x.js @@ -0,0 +1,26 @@ +declare module 'eventemitter3' { + declare type ListenerFn = (...args: any[]) => void + declare class EventEmitter { + static constructor(): EventEmitter, + static prefixed: string | boolean, + eventNames(): (string | Symbol)[], + listeners(event: string | Symbol): ListenerFn[], + listenerCount(event: string | Symbol): number, + on(event: string | Symbol, listener: ListenerFn, context?: any): this, + addListener(event: string | Symbol, listener: ListenerFn, context?: any): this, + once(event: string | Symbol, listener: ListenerFn, context?: any): this, + removeAllListeners(event?: string | Symbol): this, + removeListener(event: string | Symbol, listener?: ListenerFn, context?: any, once?: boolean): this, + off(event: string | Symbol, listener?: ListenerFn, context?: any, once?: boolean): this, + emit(event: string, ...params?: any[]): this + } + declare module.exports: Class +} + +// Filename aliases +declare module 'eventemitter3/index' { + declare module.exports: $Exports<'eventemitter3'> +} +declare module 'eventemitter3/index.js' { + declare module.exports: $Exports<'eventemitter3'> +} diff --git a/definitions/npm/eventemitter3_v3.x.x/test_eventemitter3-v3.js b/definitions/npm/eventemitter3_v3.x.x/test_eventemitter3-v3.js new file mode 100644 index 0000000000..25159d074c --- /dev/null +++ b/definitions/npm/eventemitter3_v3.x.x/test_eventemitter3-v3.js @@ -0,0 +1,47 @@ +// @flow +import EventEmitter from 'eventemitter3'; +import type { ListenerFn } from 'eventemitter3' + +class A extends EventEmitter { } + +const a: EventEmitter = new A(); + +a.on('test', () => {}); +// $ExpectError +a.on('test'); + +a.off('test'); +// $ExpectError +a.off(); + +a.removeListener('test'); +// $ExpectError +a.removeListener(); + +a.once('test', () => {}); +// $ExpectError +a.once('test'); + +a.emit('test', 'something'); +a.emit('test'); + +// a.emit(); Supposedly a bug in Flow, should expect an error here + +// $ExpectError +a.setMaxListeners(); + +// $ExpectError +a.getMaxListeners(); + +(a.listeners('emit'): ListenerFn[]); + +// appears in v3.x + +(a.listenerCount(Symbol(42)): number); + +// Breaks compatibility with v2.x +// $ExpectError +(a.listeners('emit', true): boolean); + +// $ExpectError +(a.listeners('emit', false): ListenerFn[]); From d94fd329ccf11bc93ed409258ea966386f07fe4f Mon Sep 17 00:00:00 2001 From: Saad Quadri Date: Mon, 2 Apr 2018 16:03:01 -0400 Subject: [PATCH 50/75] add xterm libdef (#2017) * add xterm * format code with prettier --- .../flow_v0.56.x-/test_xterm_v3.x.x.js | 223 +++++++++++++++ .../flow_v0.56.x-/xterm_v3.x.x.js | 255 ++++++++++++++++++ 2 files changed, 478 insertions(+) create mode 100644 definitions/npm/xterm_v3.x.x/flow_v0.56.x-/test_xterm_v3.x.x.js create mode 100644 definitions/npm/xterm_v3.x.x/flow_v0.56.x-/xterm_v3.x.x.js diff --git a/definitions/npm/xterm_v3.x.x/flow_v0.56.x-/test_xterm_v3.x.x.js b/definitions/npm/xterm_v3.x.x/flow_v0.56.x-/test_xterm_v3.x.x.js new file mode 100644 index 0000000000..b341d2831d --- /dev/null +++ b/definitions/npm/xterm_v3.x.x/flow_v0.56.x-/test_xterm_v3.x.x.js @@ -0,0 +1,223 @@ +import { Terminal } from "xterm"; + +// $ExpectError (Options should be an object) +new Terminal("{}"); +new Terminal({}); + +// $ExpectError (Can't pass invalid option) +new Terminal({ col: 1 }); +new Terminal({ cols: 1 }); + +// $ExpectError (Options must use proper type) +new Terminal({ col: 1 }); +new Terminal({ cols: 1 }); + +// None of these should throw an error +new Terminal(); +new Terminal({}); +new Terminal({ cols: 1, rows: 1 }); +new Terminal({ + cols: 1, + cursorBlink: true, + cursorStyle: "block", + disableStdin: false, + rows: 1, + scrollback: 10, + tabStopWidth: 2 +}); + +// $ExpectError (Can't use undefined static methods) +Terminal.applyAddOn({}); +Terminal.applyAddon({}); + +let terminal = new Terminal(); + +// $ExpectError (terminal.element should be an HTMLElement) +(terminal.element: string); +(terminal.element: HTMLElement); + +// $ExpectError (terminal.textarea should be an HTMLTextAreaElement) +(terminal.textarea: number); +(terminal.textarea: HTMLTextAreaElement); + +// $ExpectError (Can't use undefined instance method) +terminal.fokus(); +terminal.focus(); + +// $ExpectError (Instance methods should typecheck parameters) +terminal.write({ foo: "bar" }); +terminal.write("foobar"); + +// None of should throw an error (Mostly copied from the .d.ts test file) +terminal.blur(); +terminal.focus(); +terminal.destroy(); +terminal.clear(); +terminal.refresh(0, 1); +terminal.reset(); +terminal.resize(1, 1); +terminal.write("foo"); +terminal.writeln("foo"); +terminal.on("blur", () => {}); +terminal.on("focus", () => {}); +terminal.on("linefeed", () => {}); +terminal.on("selection", () => {}); +terminal.on("data", () => {}); +terminal.on("data", (data: string) => console.log(data)); +terminal.on("key", () => {}); +terminal.on("key", (key: string) => console.log(key)); +terminal.on("key", (key: string, event: KeyboardEvent) => + console.log(key, event) +); +terminal.on("keydown", () => {}); +terminal.on("keydown", (event: KeyboardEvent) => console.log(event)); +terminal.on("keypress", () => {}); +terminal.on("keypress", (event: KeyboardEvent) => console.log(event)); +terminal.on("refresh", () => {}); +terminal.on("refresh", (data: { start: number, end: number }) => + console.log(data) +); +terminal.on("resize", () => {}); +terminal.on("resize", (data: { cols: number, rows: number }) => + console.log(data) +); +terminal.on("scroll", () => {}); +terminal.on("scroll", (ydisp: number) => console.log(ydisp)); +terminal.on("title", () => {}); +terminal.on("title", (title: string) => console.log(title)); +terminal.off("blur", () => {}); +terminal.off("focus", () => {}); +terminal.off("linefeed", () => {}); +terminal.off("selection", () => {}); +terminal.off("data", () => {}); +terminal.off("data", (data: string) => console.log(data)); +terminal.off("key", () => {}); +terminal.off("key", (key: string) => console.log(key)); +terminal.off("key", (key: string, event: KeyboardEvent) => + console.log(key, event) +); +terminal.off("keydown", () => {}); +terminal.off("keydown", (event: KeyboardEvent) => console.log(event)); +terminal.off("keypress", () => {}); +terminal.off("keypress", (event: KeyboardEvent) => console.log(event)); +terminal.off("refresh", () => {}); +terminal.off( + "refresh", + (data: { element: HTMLElement, start: number, end: number }) => + console.log(data) +); +terminal.off("resize", () => {}); +terminal.off( + "resize", + (data: { terminal: Terminal, cols: number, rows: number }) => + console.log(data) +); +terminal.off("scroll", () => {}); +terminal.off("scroll", (ydisp: number) => console.log(ydisp)); +terminal.off("title", () => {}); +terminal.off("title", (title: string) => console.log(title)); +let e: ?HTMLElement; +e && terminal.open(e); +terminal.attachCustomKeyEventHandler((e: KeyboardEvent) => true); +terminal.attachCustomKeyEventHandler((e: KeyboardEvent) => false); +const r01: string = terminal.getOption("cursorStyle"); +const r02: string = terminal.getOption("termName"); +const r03: boolean = terminal.getOption("cancelEvents"); +const r04: boolean = terminal.getOption("convertEol"); +const r05: boolean = terminal.getOption("cursorBlink"); +const r06: boolean = terminal.getOption("debug"); +const r07: boolean = terminal.getOption("disableStdin"); +const r08: boolean = terminal.getOption("popOnBell"); +const r09: boolean = terminal.getOption("screenKeys"); +const r10: boolean = terminal.getOption("useFlowControl"); +const r11: boolean = terminal.getOption("visualBell"); +const r12: string[] = terminal.getOption("colors"); +const r13: number = terminal.getOption("cols"); +const r14: number = terminal.getOption("rows"); +const r15: number = terminal.getOption("tabStopWidth"); +const r16: number = terminal.getOption("scrollback"); +const r18: (data: string) => void = terminal.getOption("handler"); +const r19: string = terminal.getOption("bellSound"); +const r20: string = terminal.getOption("bellStyle"); +const r21: boolean = terminal.getOption("enableBold"); +const r22: number = terminal.getOption("letterSpacing"); +const r23: boolean = terminal.getOption("macOptionIsMeta"); +const r24: string = terminal.getOption("fontWeight"); +const r25: string = terminal.getOption("fontWeightBold"); +const r26: boolean = terminal.getOption("allowTransparency"); +const r27: boolean = terminal.getOption("rightClickSelectsWord"); +terminal.setOption("cursorStyle", "bar"); +terminal.setOption("cursorStyle", "block"); +terminal.setOption("cursorStyle", "underline"); +terminal.setOption("termName", "foo"); +terminal.setOption("cancelEvents", true); +terminal.setOption("convertEol", true); +terminal.setOption("cursorBlink", true); +terminal.setOption("debug", true); +terminal.setOption("disableStdin", true); +terminal.setOption("enableBold", true); +terminal.setOption("fontWeight", "normal"); +terminal.setOption("fontWeight", "bold"); +terminal.setOption("fontWeightBold", "normal"); +terminal.setOption("fontWeightBold", "bold"); +terminal.setOption("popOnBell", true); +terminal.setOption("screenKeys", true); +terminal.setOption("useFlowControl", true); +terminal.setOption("allowTransparency", true); +terminal.setOption("visualBell", true); +let colorsArr: Array = ["a", "b"]; +terminal.setOption("colors", colorsArr); +terminal.setOption("letterSpacing", 1); +terminal.setOption("cols", 1); +terminal.setOption("rows", 1); +terminal.setOption("tabStopWidth", 1); +terminal.setOption("scrollback", 1); +terminal.setOption("handler", (data: string): void => console.log(data)); +terminal.setOption("bellSound", "foo"); +terminal.setOption("bellStyle", "none"); +terminal.setOption("bellStyle", "sound"); +terminal.setOption("fontSize", 1); +terminal.setOption("lineHeight", 1); +terminal.setOption("fontFamily", "foo"); +terminal.setOption("theme", { background: "#ff0000" }); +terminal.setOption("macOptionIsMeta", true); +terminal.setOption("rightClickSelectsWord", false); +terminal.scrollLines(-1); +terminal.scrollLines(1); +terminal.scrollLines(-1); +terminal.scrollLines(1); +terminal.scrollToTop(); +terminal.scrollToBottom(); +const r1: boolean = terminal.hasSelection(); +const r2: string = terminal.getSelection(); +terminal.clearSelection(); +terminal.selectAll(); + +terminal.registerLinkMatcher(/foo/, () => {}); +terminal.registerLinkMatcher(new RegExp("foo"), () => {}); +terminal.registerLinkMatcher(/foo/, () => {}, {}); +terminal.registerLinkMatcher( + /foo/, + (event: MouseEvent, uri: string) => { + console.log(event, uri); + return void 0; + }, + {} +); +terminal.registerLinkMatcher(/foo/, () => {}, {}); +terminal.registerLinkMatcher(/foo/, () => {}, {}); +terminal.registerLinkMatcher(/foo/, () => {}, { + matchIndex: 1 +}); +terminal.registerLinkMatcher(/foo/, () => {}, { + matchIndex: 1, + priority: 1, + validationCallback: (uri: string, callback: (isValid: boolean) => void) => { + console.log(uri, callback); + }, + tooltipCallback: (e: MouseEvent, uri: string) => { + console.log(e, uri); + }, + leaveCallback: () => {} +}); +terminal.deregisterLinkMatcher(1); diff --git a/definitions/npm/xterm_v3.x.x/flow_v0.56.x-/xterm_v3.x.x.js b/definitions/npm/xterm_v3.x.x/flow_v0.56.x-/xterm_v3.x.x.js new file mode 100644 index 0000000000..2dd22f60d4 --- /dev/null +++ b/definitions/npm/xterm_v3.x.x/flow_v0.56.x-/xterm_v3.x.x.js @@ -0,0 +1,255 @@ +declare module "xterm" { + declare export type FontWeight = + | "normal" + | "bold" + | "100" + | "200" + | "300" + | "400" + | "500" + | "600" + | "700" + | "800" + | "900"; + + declare export type Theme = $Shape<{ + foreground: string, + background: string, + cursor: string, + cursorAccent: string, + selection: string, + black: string, + red: string, + green: string, + yellow: string, + blue: string, + magenta: string, + cyan: string, + white: string, + brightBlack: string, + brightRed: string, + brightGreen: string, + brightYellow: string, + brightBlue: string, + brightMagenta: string, + brightCyan: string, + brightWhite: string + }>; + + declare export type TerminalOptions = $Shape<{ + allowTransparency: boolean, + bellSound: string, + bellStyle: "none" | "sound", + cols: number, + cursorBlink: boolean, + cursorStyle: "block" | "underline" | "bar", + disableStdin: boolean, + enableBold: boolean, + fontSize: number, + fontFamily: string, + fontWeight: FontWeight, + fontWeightBold: FontWeight, + letterSpacing: number, + lineHeight: number, + macOptionIsMeta: boolean, + rightClickSelectsWord: boolean, + rows: number, + screenReaderMode: boolean, + scrollback: number, + tabStopWidth: number, + theme: Theme + }>; + + declare export type LinkMatcherOptions = $Shape<{ + matchIndex: number, + validationCallback: ( + uri: string, + callback: (isValid: boolean) => void + ) => void, + tooltipCallback: (event: MouseEvent, uri: string) => boolean | void, + leaveCallback: (event: MouseEvent, uri: string) => boolean | void, + priority: number, + willLinkActivate: (event: MouseEvent, uri: string) => boolean + }>; + + declare export type Disposable = {| + dispose(): void + |}; + + declare export type Marker = {| + ...Disposable, + +id: number, + +isDisposed: boolean, + +line: number + |}; + + declare export type LocalizableStrings = {| + blankLine: string, + promptLabel: string, + tooMuchOutput: string + |}; + + declare export class Terminal { + element: HTMLElement; + textarea: HTMLTextAreaElement; + rows: number; + cols: number; + markers: Marker[]; + static strings: LocalizableStrings; + constructor(options?: TerminalOptions): Terminal; + blur(): void; + focus(): void; + on( + type: "blur" | "focus" | "linefeed" | "selection", + listener: () => void + ): void; + on(type: "data", listener: (...args: any[]) => void): void; + on( + type: "key", + listener: (key?: string, event?: KeyboardEvent) => void + ): void; + on( + type: "keypress" | "keydown", + listener: (event?: KeyboardEvent) => void + ): void; + on( + type: "refresh", + listener: (data?: { start: number, end: number }) => void + ): void; + on( + type: "resize", + listener: (data?: { cols: number, rows: number }) => void + ): void; + on(type: "scroll", listener: (ydisp?: number) => void): void; + on(type: "title", listener: (title?: string) => void): void; + on(type: string, listener: (...args: any[]) => void): void; + off( + type: | "blur" + | "focus" + | "linefeed" + | "selection" + | "data" + | "key" + | "keypress" + | "keydown" + | "refresh" + | "resize" + | "scroll" + | "title" + | string, + listener: (...args: any[]) => void + ): void; + emit(type: string, data?: any): void; + addDisposableListener( + type: string, + handler: (...args: any[]) => void + ): Disposable; + resize(columns: number, rows: number): void; + writeln(data: string): void; + open(parent: HTMLElement): void; + attachCustomKeyEventHandler( + customKeyEventHandler: (event: KeyboardEvent) => boolean + ): void; + registerLinkMatcher( + regex: RegExp, + handler: (event: MouseEvent, uri: string) => void, + options?: LinkMatcherOptions + ): number; + deregisterLinkMatcher(matcherId: number): void; + addMarker(cursorYOffset: number): Marker; + hasSelection(): boolean; + getSelection(): string; + clearSelection(): void; + selectAll(): void; + selectLines(start: number, end: number): void; + destroy(): void; + scrollLines(amount: number): void; + scrollPages(pageCount: number): void; + scrollToTop(): void; + scrollToBottom(): void; + scrollToLine(line: number): void; + clear(): void; + write(data: string): void; + getOption( + key: | "bellSound" + | "bellStyle" + | "cursorStyle" + | "fontFamily" + | "fontWeight" + | "fontWeightBold" + | "termName" + ): string; + getOption( + key: | "allowTransparency" + | "cancelEvents" + | "convertEol" + | "cursorBlink" + | "debug" + | "disableStdin" + | "enableBold" + | "macOptionIsMeta" + | "rightClickSelectsWord" + | "popOnBell" + | "screenKeys" + | "useFlowControl" + | "visualBell" + ): boolean; + getOption(key: "colors"): Array; + getOption( + key: | "cols" + | "fontSize" + | "letterSpacing" + | "lineHeight" + | "rows" + | "tabStopWidth" + | "scrollback" + ): number; + getOption(key: "handler"): (data: string) => void; + getOption(key: string): any; + setOption( + key: "fontFamily" | "termName" | "bellSound", + value: string + ): void; + setOption(key: "fontWeight" | "fontWeightBold", value: ?FontWeight): void; + setOption( + key: "bellStyle", + value: null | "none" | "visual" | "sound" | "both" + ): void; + setOption( + key: "cursorStyle", + value: null | "block" | "underline" | "bar" + ): void; + setOption( + key: | "allowTransparency" + | "cancelEvents" + | "convertEol" + | "cursorBlink" + | "debug" + | "disableStdin" + | "enableBold" + | "macOptionIsMeta" + | "popOnBell" + | "rightClickSelectsWord" + | "screenKeys" + | "useFlowControl" + | "visualBell", + value: boolean + ): void; + setOption(key: "colors", value: Array): void; + setOption( + key: | "fontSize" + | "letterSpacing" + | "lineHeight" + | "tabStopWidth" + | "scrollback", + value: number + ): void; + setOption(key: "handler", value: (data: string) => void): void; + setOption(key: "theme", value: Theme): void; + setOption(key: "cols" | "rows", value: number): void; + setOption(key: string, value: any): void; + refresh(start: number, end: number): void; + reset(): void; + static applyAddon(addon: any): void; + } +} From 4940ac8b5a820888716208cdeaf50dea4170c727 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Mon, 2 Apr 2018 20:14:35 -0400 Subject: [PATCH 51/75] add select() and put.resolve() (#1707) --- .../flow_v0.56.0-/redux-saga_v0.16.x.js | 9 +++++++-- .../flow_v0.56.0-/test_redux-saga_0.16.x.js | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/redux-saga_v0.16.x.js b/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/redux-saga_v0.16.x.js index 54a61d51f3..bca5913181 100644 --- a/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/redux-saga_v0.16.x.js +++ b/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/redux-saga_v0.16.x.js @@ -287,7 +287,7 @@ declare module "redux-saga" { +CANCEL: T }; - declare export type SelectEffect> = { + declare export type SelectEffect> = { +"@@redux-saga/IO": true, +SELECT: { +selector: Fn, @@ -391,7 +391,11 @@ declare module "redux-saga/effects" { declare export var put: { (action: A): PutEffect, - (channel: Channel, action: A): PutEffect + (channel: Channel, action: A): PutEffect, + resolve: { + (action: A): PutEffect, + (channel: Channel, action: A): PutEffect, + } }; declare export var call: { @@ -974,6 +978,7 @@ declare module "redux-saga/effects" { }; declare export var select: { + (): SelectEffect, R>(fn: Fn): SelectEffect, R>( fn: Fn, diff --git a/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/test_redux-saga_0.16.x.js b/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/test_redux-saga_0.16.x.js index b20e7c1b11..66d0a609b3 100644 --- a/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/test_redux-saga_0.16.x.js +++ b/definitions/npm/redux-saga_v0.16.x/flow_v0.56.0-/test_redux-saga_0.16.x.js @@ -295,6 +295,23 @@ function putTest() { // $ExpectError: This property cannot be inferred (put1.PUT.action.unknown: string); + + put.resolve({ type: "test" }); + + const put3 = put.resolve({ type: "FOO", baz: "hi" }); + (put3.PUT.action.baz: string); + + const put4 = put.resolve(myChannel, { type: "test" }); + (put4.PUT.channel: Channel); + + // $ExpectError: Can only be called with objects + put.resolve("FOO"); + + // $ExpectError: No null as channel accepted + put.resolve(null, { type: "test" }); + + // $ExpectError: This property cannot be inferred + (put3.PUT.action.unknown: string); } function actionChannelTest() { @@ -1204,6 +1221,7 @@ function selectTest() { ) => ({}); const sSpread = (state: Object, ...args: Array): Object => ({}); + const eVoid = select(); const e0 = select(s0); const e1 = select(s1, "1"); const e2 = select(s2, "1", 2); @@ -1213,6 +1231,7 @@ function selectTest() { const e6 = select(s6, "1", 2, "3", 4, "5", 6); // Args test + (eVoid.SELECT.args: []); (e0.SELECT.args: []); (e1.SELECT.args: [string]); (e2.SELECT.args: [string, number]); @@ -1225,6 +1244,7 @@ function selectTest() { (e3.SELECT.args: [string, boolean, string]); // Fn check + (eVoid.SELECT.selector: void); (e0.SELECT.selector: typeof s0); (e1.SELECT.selector: typeof s1); (e2.SELECT.selector: typeof s2); From 5123ba71af88c48c344cb882bb3bd99255ca6d9e Mon Sep 17 00:00:00 2001 From: Oleg Nechiporenko Date: Tue, 3 Apr 2018 03:16:47 +0300 Subject: [PATCH 52/75] Added actionCodeSettings type (#2021) Added parameter for sendEmailVerificationMethod Changed onAuthStateChanged handler signature --- .../flow_v0.34.x-/firebase_v4.x.x.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js b/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js index e333a66075..032b099df3 100644 --- a/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js +++ b/definitions/npm/firebase_v4.x.x/flow_v0.34.x-/firebase_v4.x.x.js @@ -102,12 +102,12 @@ declare class $npm$firebase$auth$Auth { ): Promise<$npm$firebase$auth$User>; fetchProvidersForEmail(email: string): Promise>; onAuthStateChanged( - nextOrObserver: (?$npm$firebase$auth$User) => void, + nextOrObserver: (?$npm$firebase$auth$User) => void | Promise, error?: (error: $npm$firebase$auth$Error) => void, completed?: () => void ): () => void; onIdTokenChanged( - nextOrObserver: Object | ((user?: $npm$firebase$auth$User) => void), + nextOrObserver: Object | ((user?: $npm$firebase$auth$User) => void | Promise), error?: (error: $npm$firebase$auth$Error) => void, completed?: () => void ): () => void; @@ -176,6 +176,17 @@ declare class $npm$firebase$auth$UserInfo { uid: string; } +declare type $npm$firebase$actionCode$settings = { + url: string, + iOS?: { bundleId: string }, + android?: { + packageName: string, + installApp?: boolean, + minimumVersion?: string, + }, + handleCodeInApp?: boolean, +} + declare class $npm$firebase$auth$User extends $npm$firebase$auth$UserInfo { displayName: ?string; email: ?string; @@ -214,7 +225,7 @@ declare class $npm$firebase$auth$User extends $npm$firebase$auth$UserInfo { applicationVerifier: $npm$firebase$auth$ApplicationVerifier ): Promise<$npm$firebase$auth$ConfirmationResult>; reload(): Promise; - sendEmailVerification(): Promise; + sendEmailVerification(actionCodeSettings?: $npm$firebase$actionCode$settings): Promise; toJSON(): Object; unlink(providerId: string): Promise<$npm$firebase$auth$User>; updateEmail(newEmail: string): Promise; From 6e88c0d84bc8180ac13318e882d398280eeedc49 Mon Sep 17 00:00:00 2001 From: Alex Dong Date: Tue, 3 Apr 2018 12:18:31 +1200 Subject: [PATCH 53/75] Add two missing exports to `react-bootstrap` (#2024) `Pagination.Last` and `Pagination.Next` according to https://react-bootstrap.github.io/components/pagination/ --- .../flow_v0.53.x-/react-bootstrap_v0.32.x.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js b/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js index 3cfba03c43..226a3749e9 100644 --- a/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js +++ b/definitions/npm/react-bootstrap_v0.32.x/flow_v0.53.x-/react-bootstrap_v0.32.x.js @@ -446,10 +446,19 @@ declare module "react-bootstrap" { bsClass?: string }> {} + + declare class PaginationLast extends React$Component<{ + bsClass?: string + }> {} + declare class PaginationPrev extends React$Component<{ bsClass?: string }> {} - + + declare class PaginationNext extends React$Component<{ + bsClass?: string + }> {} + declare class PaginationEllipsis extends React$Component<{ bsClass?: string }> {} @@ -459,7 +468,9 @@ declare module "react-bootstrap" { }> { static Item: Class; static First: Class; + static Last: Class; static Prev: Class; + static Next: Class; static Ellipsis: Class; } From 7089f101b46e843bf5393f8ff0e5c00619b3515b Mon Sep 17 00:00:00 2001 From: "M. Walker Wells" Date: Tue, 3 Apr 2018 05:59:39 -0700 Subject: [PATCH 54/75] Removed global and renamed export to be less confusing. (#2022) --- .../flow_v0.34.x-/fluture_v6.x.x.js | 101 +++++++++--------- 1 file changed, 49 insertions(+), 52 deletions(-) diff --git a/definitions/npm/fluture_v6.x.x/flow_v0.34.x-/fluture_v6.x.x.js b/definitions/npm/fluture_v6.x.x/flow_v0.34.x-/fluture_v6.x.x.js index 5415dab685..c37848e5e0 100644 --- a/definitions/npm/fluture_v6.x.x/flow_v0.34.x-/fluture_v6.x.x.js +++ b/definitions/npm/fluture_v6.x.x/flow_v0.34.x-/fluture_v6.x.x.js @@ -5,54 +5,53 @@ // helpers type $npm$Fluture$Fn1 = (a: A) => B // a unary function -// Create the global type Fluture -// Rej = type of returned rejected value -// Res = type of returned resolved value -declare class Fluture { - map: (fn: $npm$Fluture$Fn1) => Fluture, - bimap: ( - left: $npm$Fluture$Fn1, - right: $npm$Fluture$Fn1 - ) => Fluture, - chain: (fn: (a: Res) => Fluture) => Fluture, - swap: () => Fluture, - mapRej: (fn: $npm$Fluture$Fn1) => Fluture, - chainRej: (fn: (a: Rej) => Fluture) => Fluture, - // We can't type fold with 2 different types of left and right - fold: ( - left: $npm$Fluture$Fn1, - right: $npm$Fluture$Fn1 - ) => Fluture, - // We can't infer the type of applied Res(B) - ap: (a: Fluture) => Fluture, - // We can't infer the first reject or resolve - and: (a: Fluture) => Fluture, - // We can't infer the last reject or resolve - or: (a: Fluture) => Fluture, - - finally: (a: Fluture<*, *>) => Fluture, - lastly: (a: Fluture<*, *>) => Fluture, - - fork: ( - rej: $npm$Fluture$Fn1, - res: $npm$Fluture$Fn1 - ) => () => *, - value: (res: $npm$Fluture$Fn1) => () => *, - promise: () => Promise, - - // We can't infer the first reject or resolve - race: (a: Fluture) => Fluture -} - declare module fluture { declare type Computation = ( rej: $npm$Fluture$Fn1, - res: $npm$Fluture$Fn1 + res: $npm$Fluture$Fn1, ) => void declare type NodeBack = (rej: Rej, res: Res) => void - declare class Future { + // Rej = type of returned rejected value + // Res = type of returned resolved value + declare class Fluture { + map: (fn: $npm$Fluture$Fn1) => Fluture; + bimap: ( + left: $npm$Fluture$Fn1, + right: $npm$Fluture$Fn1, + ) => Fluture; + chain: (fn: (a: Res) => Fluture) => Fluture; + swap: () => Fluture; + mapRej: (fn: $npm$Fluture$Fn1) => Fluture; + chainRej: (fn: (a: Rej) => Fluture) => Fluture; + // We can't type fold with 2 different types of left and right + fold: ( + left: $npm$Fluture$Fn1, + right: $npm$Fluture$Fn1, + ) => Fluture; + // We can't infer the type of applied Res(B) + ap: (a: Fluture) => Fluture; + // We can't infer the first reject or resolve + and: (a: Fluture) => Fluture; + // We can't infer the last reject or resolve + or: (a: Fluture) => Fluture; + + finally: (a: Fluture<*, *>) => Fluture; + lastly: (a: Fluture<*, *>) => Fluture; + + fork: ( + rej: $npm$Fluture$Fn1, + res: $npm$Fluture$Fn1, + ) => () => *; + value: (res: $npm$Fluture$Fn1) => () => *; + promise: () => Promise; + + // We can't infer the first reject or resolve + race: (a: Fluture) => Fluture; + } + + declare module.exports: { of: (a: T) => Fluture<*, T>, reject: (a: T) => Fluture, after: (a: number, b: T) => Fluture, @@ -66,31 +65,31 @@ declare module fluture { encase: (fn: (a: A) => B) => (a: A) => Fluture<*, B>, encase2: ( - fn: (a1: A1, a2: A2) => B + fn: (a1: A1, a2: A2) => B, ) => (a1: A1, a2: A2) => Fluture<*, B>, encase3: ( - fn: (a1: A1, a2: A2, a3: A3) => B + fn: (a1: A1, a2: A2, a3: A3) => B, ) => (a1: A1, a2: A2, a3: A3) => Fluture<*, B>, encaseP: (fn: (a: A) => Promise) => (a: A) => Fluture<*, B>, encaseP2: ( - fn: (a1: A1, a2: A2) => Promise + fn: (a1: A1, a2: A2) => Promise, ) => (a1: A1, a2: A2) => Fluture<*, B>, encaseP3: ( - fn: (a1: A1, a2: A2, a3: A3) => Promise + fn: (a1: A1, a2: A2, a3: A3) => Promise, ) => (a1: A1, a2: A2, a3: A3) => Fluture<*, B>, encaseN: ( - fn: (a: A, done: NodeBack) => void + fn: (a: A, done: NodeBack) => void, ) => (a: A) => Fluture, encaseN2: ( - fn: (a1: A1, a2: A2, done: NodeBack) => void + fn: (a1: A1, a2: A2, done: NodeBack) => void, ) => (a1: A1, a2: A2) => Fluture, encaseN3: ( - fn: (a1: A1, a2: A2, a3: A3, done: NodeBack) => void + fn: (a1: A1, a2: A2, a3: A3, done: NodeBack) => void, ) => (a1: A1, a2: A2, a3: A3) => Fluture, hook: ( f1: Fluture, - f2: (b: B) => Fluture + f2: (b: B) => Fluture, ) => (f3: (c: B) => Fluture) => Fluture, both: (a: Fluture, Fluture) => Fluture, @@ -105,8 +104,6 @@ declare module fluture { isNever: (a: *) => boolean, never: () => Fluture, - (fn: Computation): Fluture + (fn: Computation): Fluture, } - - declare module.exports: Future } From f6dc3bf38ddc631152f359c1d7823df2f3589457 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Wed, 4 Apr 2018 02:15:45 +0800 Subject: [PATCH 55/75] update material-ui flow defs (#2009) --- .../material-ui_v1.x.x.js | 481 ++++++++++++++---- .../test_all_imports_material-ui_v1.x.x.js | 107 ++++ .../test_module_imports_material-ui_v1.x.x.js | 103 ++++ 3 files changed, 585 insertions(+), 106 deletions(-) rename definitions/npm/material-ui_v1.x.x/{flow_v0.61.x- => flow_v0.58.x-}/material-ui_v1.x.x.js (81%) create mode 100644 definitions/npm/material-ui_v1.x.x/test_all_imports_material-ui_v1.x.x.js create mode 100644 definitions/npm/material-ui_v1.x.x/test_module_imports_material-ui_v1.x.x.js diff --git a/definitions/npm/material-ui_v1.x.x/flow_v0.61.x-/material-ui_v1.x.x.js b/definitions/npm/material-ui_v1.x.x/flow_v0.58.x-/material-ui_v1.x.x.js similarity index 81% rename from definitions/npm/material-ui_v1.x.x/flow_v0.61.x-/material-ui_v1.x.x.js rename to definitions/npm/material-ui_v1.x.x/flow_v0.58.x-/material-ui_v1.x.x.js index cf4c0ec703..41512b2d15 100644 --- a/definitions/npm/material-ui_v1.x.x/flow_v0.61.x-/material-ui_v1.x.x.js +++ b/definitions/npm/material-ui_v1.x.x/flow_v0.58.x-/material-ui_v1.x.x.js @@ -76,12 +76,12 @@ declare module "material-ui/BottomNavigation/BottomNavigationAction" { } declare module "material-ui/BottomNavigation" { - declare module.exports: { - BottomNavigationAction: $Exports< - "material-ui/BottomNavigation/BottomNavigationAction" - >, - default: $Exports<"material-ui/BottomNavigation/BottomNavigation"> - }; + declare export var BottomNavigationAction: $Exports< + "material-ui/BottomNavigation/BottomNavigationAction" + >; + declare export default $Exports< + "material-ui/BottomNavigation/BottomNavigation" + >; } declare module "material-ui/Button/Button" { @@ -217,13 +217,11 @@ declare module "material-ui/Card/CardMedia" { } declare module "material-ui/Card" { - declare module.exports: { - CardActions: $Exports<"material-ui/Card/CardActions">, - CardContent: $Exports<"material-ui/Card/CardContent">, - CardHeader: $Exports<"material-ui/Card/CardHeader">, - CardMedia: $Exports<"material-ui/Card/CardMedia">, - default: $Exports<"material-ui/Card/Card"> - }; + declare export var CardActions: $Exports<"material-ui/Card/CardActions">; + declare export var CardContent: $Exports<"material-ui/Card/CardContent">; + declare export var CardHeader: $Exports<"material-ui/Card/CardHeader">; + declare export var CardMedia: $Exports<"material-ui/Card/CardMedia">; + declare export default $Exports<"material-ui/Card/Card">; } declare module "material-ui/Checkbox/Checkbox" { @@ -271,6 +269,14 @@ declare module "material-ui/Chip" { declare module.exports: $Exports<"material-ui/Chip/Chip">; } +declare module "material-ui/CssBaseline/CssBaseline" { + declare module.exports: React$ComponentType<{ children?: React$Node }>; +} + +declare module "material-ui/CssBaseline" { + declare module.exports: $Exports<"material-ui/CssBaseline/CssBaseline">; +} + declare module "material-ui/colors/amber" { declare module.exports: any; } @@ -420,14 +426,20 @@ declare module "material-ui/Dialog/DialogTitle" { } declare module "material-ui/Dialog" { - declare module.exports: { - DialogActions: $Exports<"material-ui/Dialog/DialogActions">, - DialogContent: $Exports<"material-ui/Dialog/DialogContent">, - DialogContentText: $Exports<"material-ui/Dialog/DialogContentText">, - DialogTitle: $Exports<"material-ui/Dialog/DialogTitle">, - default: $Exports<"material-ui/Dialog/Dialog">, - withMobileDialog: $Exports<"material-ui/Dialog/withMobileDialog"> - }; + declare export var DialogActions: $Exports< + "material-ui/Dialog/DialogActions" + >; + declare export var DialogContent: $Exports< + "material-ui/Dialog/DialogContent" + >; + declare export var DialogContentText: $Exports< + "material-ui/Dialog/DialogContentText" + >; + declare export var DialogTitle: $Exports<"material-ui/Dialog/DialogTitle">; + declare export var withMobileDialog: $Exports< + "material-ui/Dialog/withMobileDialog" + >; + declare export default $Exports<"material-ui/Dialog/Dialog">; } declare module "material-ui/Dialog/withMobileDialog" { @@ -468,11 +480,37 @@ declare module "material-ui/Drawer/Drawer" { type?: Type }>; } - declare module "material-ui/Drawer" { declare module.exports: $Exports<"material-ui/Drawer/Drawer">; } +declare module "material-ui/SwipeableDrawer/SwipeableDrawer" { + import type { TransitionDuration } from "material-ui/internal/transition"; + + declare type Anchor = "left" | "top" | "right" | "bottom"; + declare type Type = "permanent" | "persistent" | "temporary"; + + declare module.exports: React$ComponentType<{ + ModalProps?: Object, + SlideProps?: Object, + anchor?: Anchor, + children: React$Node, + className?: string, + classes?: Object, + elevation?: number, + onClose?: Function, + open?: boolean, + transitionDuration?: TransitionDuration, + type?: Type + }>; +} + +declare module "material-ui/SwipeableDrawer" { + declare module.exports: $Exports< + "material-ui/SwipeableDrawer/SwipeableDrawer" + >; +} + declare module "material-ui/ExpansionPanel/ExpansionPanel" { declare module.exports: React$ComponentType<{ CollapseProps?: Object, @@ -516,18 +554,16 @@ declare module "material-ui/ExpansionPanel/ExpansionPanelSummary" { } declare module "material-ui/ExpansionPanel" { - declare module.exports: { - default: $Exports<"material-ui/ExpansionPanel/ExpansionPanel">, - ExpansionPanelActions: $Exports< - "material-ui/ExpansionPanel/ExpansionPanelActions" - >, - ExpansionPanelDetails: $Exports< - "material-ui/ExpansionPanel/ExpansionPanelDetails" - >, - ExpansionPanelSummary: $Exports< - "material-ui/ExpansionPanel/ExpansionPanelSummary" - > - }; + declare export default $Exports<"material-ui/ExpansionPanel/ExpansionPanel">; + declare export var ExpansionPanelActions: $Exports< + "material-ui/ExpansionPanel/ExpansionPanelActions" + >; + declare export var ExpansionPanelDetails: $Exports< + "material-ui/ExpansionPanel/ExpansionPanelDetails" + >; + declare export var ExpansionPanelSummary: $Exports< + "material-ui/ExpansionPanel/ExpansionPanelSummary" + >; } declare module "material-ui/Form/FormControl" { @@ -712,12 +748,14 @@ declare module "material-ui/GridList/GridListTileBar" { } declare module "material-ui/GridList" { - declare module.exports: { - default: $Exports<"material-ui/GridList/GridList">, - GridList: $Exports<"material-ui/GridList/GridList">, - GridListTile: $Exports<"material-ui/GridList/GridListTile">, - GridListTileBar: $Exports<"material-ui/GridList/GridListTileBar"> - }; + declare export default $Exports<"material-ui/GridList/GridList">; + declare export var GridList: $Exports<"material-ui/GridList/GridList">; + declare export var GridListTile: $Exports< + "material-ui/GridList/GridListTile" + >; + declare export var GridListTileBar: $Exports< + "material-ui/GridList/GridListTileBar" + >; } declare module "material-ui/Hidden/Hidden" { @@ -755,10 +793,8 @@ declare module "material-ui/Hidden/HiddenJs" { } declare module "material-ui/Hidden" { - declare module.exports: { - default: $Exports<"material-ui/Hidden/Hidden">, - HiddenJs: $Exports<"material-ui/Hidden/HiddenJs"> - }; + declare export default $Exports<"material-ui/Hidden/Hidden">; + declare export var HiddenJs: $Exports<"material-ui/Hidden/HiddenJs">; } declare module "material-ui/Hidden/types" { @@ -812,11 +848,11 @@ declare module "material-ui/IconButton" { } declare module "material-ui/Input" { - declare module.exports: { - default: $Exports<"material-ui/Input/Input">, - InputAdornment: $Exports<"material-ui/Input/InputAdornment">, - InputLabel: $Exports<"material-ui/Input/InputLabel"> - }; + declare export default $Exports<"material-ui/Input/Input">; + declare export var InputAdornment: $Exports< + "material-ui/Input/InputAdornment" + >; + declare export var InputLabel: $Exports<"material-ui/Input/InputLabel">; } declare module "material-ui/Input/Input" { @@ -902,13 +938,17 @@ declare module "material-ui/internal/dom" { declare module.exports: any; } -declare module "material-ui/internal/Portal" { +declare module "material-ui/Portal/Portal" { declare module.exports: React$ComponentType<{ children?: React$Node, open?: boolean }>; } +declare module "material-ui/Portal" { + declare module.exports: $Exports<"material-ui/Portal/Portal">; +} + declare module "material-ui/internal/SwitchBase" { declare module.exports: React$ComponentType<{ checked?: boolean | string, @@ -1035,11 +1075,9 @@ declare module "material-ui/List/ListSubheader" { } declare module "material-ui/Menu" { - declare module.exports: { - default: $Exports<"material-ui/Menu/Menu">, - MenuList: $Exports<"material-ui/Menu/MenuList">, - MenuItem: $Exports<"material-ui/Menu/MenuItem"> - }; + declare export default $Exports<"material-ui/Menu/Menu">; + declare export var MenuList: $Exports<"material-ui/Menu/MenuList">; + declare export var MenuItem: $Exports<"material-ui/Menu/MenuItem">; } declare module "material-ui/Menu/Menu" { @@ -1118,8 +1156,20 @@ declare module "material-ui/Modal/Backdrop" { }>; } +declare module "material-ui/Modal/ModalManager" { + declare class ModalManager { + constructor(Object): ModalManager; + add(any, any): void; + remove(any): number; + isTopModal(modal: any): boolean; + } + declare export default typeof ModalManager; +} + declare module "material-ui/Modal" { - declare module.exports: $Exports<"material-ui/Modal/Modal">; + declare export var Backdrop: $Exports<"material-ui/Modal/Backdrop">; + declare export var ModalManager: $Exports<"material-ui/Modal/ModalManager">; + declare export default $Exports<"material-ui/Modal/Modal">; } declare module "material-ui/Modal/Modal" { @@ -1259,10 +1309,8 @@ declare module "material-ui/Progress/LinearProgress" { } declare module "material-ui/Radio" { - declare module.exports: { - default: $Exports<"material-ui/Radio/Radio">, - RadioGroup: $Exports<"material-ui/Radio/RadioGroup"> - }; + declare export default $Exports<"material-ui/Radio/Radio">; + declare export var RadioGroup: $Exports<"material-ui/Radio/RadioGroup">; } declare module "material-ui/Radio/Radio" { @@ -1345,10 +1393,10 @@ declare module "material-ui/Select/SelectInput" { } declare module "material-ui/Snackbar" { - declare module.exports: { - default: $Exports<"material-ui/Snackbar/Snackbar">, - SnackbarContent: $Exports<"material-ui/Snackbar/SnackbarContent"> - }; + declare export default $Exports<"material-ui/Snackbar/Snackbar">; + declare export var SnackbarContent: $Exports< + "material-ui/Snackbar/SnackbarContent" + >; } declare module "material-ui/Snackbar/Snackbar" { @@ -1398,13 +1446,12 @@ declare module "material-ui/Snackbar/SnackbarContent" { } declare module "material-ui/Stepper" { - declare module.exports: { - default: $Exports<"material-ui/Stepper/Stepper">, - Step: $Exports<"material-ui/Stepper/Step">, - StepButton: $Exports<"material-ui/Stepper/StepButton">, - StepContent: $Exports<"material-ui/Stepper/StepContent">, - StepLabel: $Exports<"material-ui/Stepper/StepLabel"> - }; + declare export default $Exports<"material-ui/Stepper/Stepper">; + declare export var Step: $Exports<"material-ui/Stepper/Step">; + declare export var StepButton: $Exports<"material-ui/Stepper/StepButton">; + declare export var StepContent: $Exports<"material-ui/Stepper/StepContent">; + declare export var StepIcon: $Exports<"material-ui/Stepper/StepIcon">; + declare export var StepLabel: $Exports<"material-ui/Stepper/StepLabel">; } declare module "material-ui/Stepper/Step" { @@ -1576,11 +1623,9 @@ declare module "material-ui/styles/createMuiTheme" { } declare module "material-ui/styles/createPalette" { - declare module.exports: { - light: Object, - dark: Object, - default: (palette: Object) => any - }; + declare export var light: Object; + declare export var dark: Object; + declare export default (palette: Object) => any; } declare module "material-ui/styles/createTypography" { @@ -1590,6 +1635,10 @@ declare module "material-ui/styles/createTypography" { ) => any; } +declare module "material-ui/styles/jssPreset" { + declare module.exports: () => any; +} + declare module "material-ui/styles/getStylesCreator" { declare module.exports: (stylesOrCreator: Object | (Object => Object)) => any; } @@ -1599,7 +1648,8 @@ declare module "material-ui/styles" { MuiThemeProvider: $Exports<"material-ui/styles/MuiThemeProvider">, withStyles: $Exports<"material-ui/styles/withStyles">, withTheme: $Exports<"material-ui/styles/withTheme">, - createMuiTheme: $Exports<"material-ui/styles/createMuiTheme"> + createMuiTheme: $Exports<"material-ui/styles/createMuiTheme">, + jssPreset: $Exports<"material-ui/styles/jssPreset"> }; } @@ -1616,21 +1666,17 @@ declare module "material-ui/styles/spacing" { } declare module "material-ui/styles/themeListener" { - declare module.exports: { - CHANNEL: string, - default: Object - }; + declare export var CHANNEL: string; + declare export default Object; } declare module "material-ui/styles/transitions" { - declare module.exports: { - easing: Object, - duration: Object, - formatMs: (milliseconds: number) => string, - isString: (value: any) => boolean, - isNumber: (value: any) => boolean, - default: Object - }; + declare export var easing: Object; + declare export var duration: Object; + declare export var formatMs: (milliseconds: number) => string; + declare export var isString: (value: any) => boolean; + declare export var isNumber: (value: any) => boolean; + declare export default Object; } declare module "material-ui/styles/withStyles" { @@ -1754,16 +1800,18 @@ declare module "material-ui/Switch/Switch" { } declare module "material-ui/Table" { - declare module.exports: { - default: $Exports<"material-ui/Table/Table">, - TableBody: $Exports<"material-ui/Table/TableBody">, - TableCell: $Exports<"material-ui/Table/TableCell">, - TableFooter: $Exports<"material-ui/Table/TableFooter">, - TableHead: $Exports<"material-ui/Table/TableHead">, - TablePagination: $Exports<"material-ui/Table/TablePagination">, - TableRow: $Exports<"material-ui/Table/TableRow">, - TableSortLabel: $Exports<"material-ui/Table/TableSortLabel"> - }; + declare export default $Exports<"material-ui/Table/Table">; + declare export var TableBody: $Exports<"material-ui/Table/TableBody">; + declare export var TableCell: $Exports<"material-ui/Table/TableCell">; + declare export var TableFooter: $Exports<"material-ui/Table/TableFooter">; + declare export var TableHead: $Exports<"material-ui/Table/TableHead">; + declare export var TablePagination: $Exports< + "material-ui/Table/TablePagination" + >; + declare export var TableRow: $Exports<"material-ui/Table/TableRow">; + declare export var TableSortLabel: $Exports< + "material-ui/Table/TableSortLabel" + >; } declare module "material-ui/Table/Table" { @@ -1865,10 +1913,8 @@ declare module "material-ui/Table/TableSortLabel" { } declare module "material-ui/Tabs" { - declare module.exports: { - default: $Exports<"material-ui/Tabs/Tabs">, - Tab: $Exports<"material-ui/Tabs/Tab"> - }; + declare export default $Exports<"material-ui/Tabs/Tabs">; + declare export var Tab: $Exports<"material-ui/Tabs/Tab">; } declare module "material-ui/Tabs/Tab" { @@ -2076,6 +2122,22 @@ declare module "material-ui/transitions/Fade" { }>; } +declare module "material-ui/transitions/Zoom" { + import type { + TransitionDuration, + TransitionCallback + } from "material-ui/internal/transition"; + + declare module.exports: React$ComponentType<{ + children: React$Element, + in: boolean, + onEnter?: TransitionCallback, + onExit?: TransitionCallback, + style?: Object, + timeout?: TransitionDuration + }>; +} + declare module "material-ui/transitions/Grow" { import type { TransitionCallback, @@ -2109,7 +2171,8 @@ declare module "material-ui/transitions" { Slide: $Exports<"material-ui/transitions/Slide">, Grow: $Exports<"material-ui/transitions/Grow">, Fade: $Exports<"material-ui/transitions/Fade">, - Collapse: $Exports<"material-ui/transitions/Collapse"> + Collapse: $Exports<"material-ui/transitions/Collapse">, + Zoom: $Exports<"material-ui/transitions/Zoom"> }; } @@ -2254,6 +2317,30 @@ declare module "material-ui/utils/withWidth" { ) => React$ComponentType; } +declare module "material-ui/colors" { + declare export var withWidth: $Exports<"material-ui/utils/withWidth">; + declare export var common: $Exports<"material-ui/colors/common">; + declare export var red: $Exports<"material-ui/colors/red">; + declare export var pink: $Exports<"material-ui/colors/pink">; + declare export var purple: $Exports<"material-ui/colors/purple">; + declare export var deepPurple: $Exports<"material-ui/colors/deepPurple">; + declare export var indigo: $Exports<"material-ui/colors/indigo">; + declare export var blue: $Exports<"material-ui/colors/blue">; + declare export var lightBlue: $Exports<"material-ui/colors/lightBlue">; + declare export var cyan: $Exports<"material-ui/colors/cyan">; + declare export var teal: $Exports<"material-ui/colors/teal">; + declare export var green: $Exports<"material-ui/colors/green">; + declare export var lightGreen: $Exports<"material-ui/colors/lightGreen">; + declare export var lime: $Exports<"material-ui/colors/lime">; + declare export var yellow: $Exports<"material-ui/colors/yellow">; + declare export var amber: $Exports<"material-ui/colors/amber">; + declare export var orange: $Exports<"material-ui/colors/orange">; + declare export var deepOrange: $Exports<"material-ui/colors/deepOrange">; + declare export var brown: $Exports<"material-ui/colors/brown">; + declare export var grey: $Exports<"material-ui/colors/grey">; + declare export var blueGrey: $Exports<"material-ui/colors/blueGrey">; +} + // Filename aliases declare module "material-ui/AppBar/AppBar.js" { declare module.exports: $Exports<"material-ui/AppBar/AppBar">; @@ -2537,8 +2624,8 @@ declare module "material-ui/Input/Textarea.js" { declare module "material-ui/internal/dom.js" { declare module.exports: $Exports<"material-ui/internal/dom">; } -declare module "material-ui/internal/Portal.js" { - declare module.exports: $Exports<"material-ui/internal/Portal">; +declare module "material-ui/Portal/Portal.js" { + declare module.exports: $Exports<"material-ui/Portal">; } declare module "material-ui/internal/SwitchBase.js" { declare module.exports: $Exports<"material-ui/internal/SwitchBase">; @@ -2887,3 +2974,185 @@ declare module "material-ui/utils/requirePropFactory.js" { declare module "material-ui/utils/withWidth.js" { declare module.exports: $Exports<"material-ui/utils/withWidth">; } + +declare module "material-ui" { + declare export var AppBar: $Exports<"material-ui/AppBar/AppBar">; + declare export var Avatar: $Exports<"material-ui/Avatar/Avatar">; + declare export var Badge: $Exports<"material-ui/Badge/Badge">; + declare export var BottomNavigationAction: $Exports< + "material-ui/BottomNavigation/BottomNavigationAction" + >; + + declare export var BottomNavigation: $Exports< + "material-ui/BottomNavigation/BottomNavigation" + >; + declare export var Button: $Exports<"material-ui/Button/Button">; + declare export var ButtonBase: $Exports<"material-ui/ButtonBase/ButtonBase">; + declare export var Card: $Exports<"material-ui/Card/Card">; + declare export var CardActions: $Exports<"material-ui/Card/CardActions">; + declare export var CardContent: $Exports<"material-ui/Card/CardContent">; + declare export var CardHeader: $Exports<"material-ui/Card/CardHeader">; + declare export var CardMedia: $Exports<"material-ui/Card/CardMedia">; + declare export var Checkbox: $Exports<"material-ui/Checkbox/Checkbox">; + declare export var Chip: $Exports<"material-ui/Chip/Chip">; + declare export var ClickAwayListener: $Exports< + "material-ui/utils/ClickAwayListener" + >; + declare export var CssBaseline: $Exports< + "material-ui/CssBaseline/CssBaseline" + >; + + declare export var Dialog: $Exports<"material-ui/Dialog/Dialog">; + declare export var DialogActions: $Exports< + "material-ui/Dialog/DialogActions" + >; + declare export var DialogContent: $Exports< + "material-ui/Dialog/DialogContent" + >; + declare export var DialogContentText: $Exports< + "material-ui/Dialog/DialogContentText" + >; + declare export var DialogTitle: $Exports<"material-ui/Dialog/DialogTitle">; + declare export var withMobileDialog: $Exports< + "material-ui/Dialog/withMobileDialog" + >; + declare export var Divider: $Exports<"material-ui/Divider/Divider">; + declare export var Drawer: $Exports<"material-ui/Drawer/Drawer">; + declare export var ExpansionPanel: $Exports< + "material-ui/ExpansionPanel/ExpansionPanel" + >; + declare export var ExpansionPanelActions: $Exports< + "material-ui/ExpansionPanel/ExpansionPanelActions" + >; + declare export var ExpansionPanelDetails: $Exports< + "material-ui/ExpansionPanel/ExpansionPanelDetails" + >; + declare export var ExpansionPanelSummary: $Exports< + "material-ui/ExpansionPanel/ExpansionPanelSummary" + >; + + declare export var FormControl: $Exports<"material-ui/Form/FormControl">; + declare export var FormGroup: $Exports<"material-ui/Form/FormGroup">; + declare export var FormLabel: $Exports<"material-ui/Form/FormLabel">; + declare export var FormHelperText: $Exports< + "material-ui/Form/FormHelperText" + >; + declare export var FormControlLabel: $Exports< + "material-ui/Form/FormControlLabel" + >; + declare export var Hidden: $Exports<"material-ui/Hidden/Hidden">; + declare export var Icon: $Exports<"material-ui/Icon/Icon">; + declare export var IconButton: $Exports<"material-ui/IconButton/IconButton">; + declare export var Input: $Exports<"material-ui/Input/Input">; + declare export var InputLabel: $Exports<"material-ui/Input/InputLabel">; + declare export var InputAdornment: $Exports< + "material-ui/Input/InputAdornment" + >; + declare export var Grid: $Exports<"material-ui/Grid/Grid">; + declare export var GridList: $Exports<"material-ui/GridList/GridList">; + declare export var GridListTile: $Exports< + "material-ui/GridList/GridListTile" + >; + declare export var GridListTileBar: $Exports< + "material-ui/GridList/GridListTileBar" + >; + declare export var List: $Exports<"material-ui/List/List">; + declare export var ListItem: $Exports<"material-ui/List/ListItem">; + declare export var ListItemAvatar: $Exports< + "material-ui/List/ListItemAvatar" + >; + declare export var ListItemIcon: $Exports<"material-ui/List/ListItemIcon">; + declare export var ListItemSecondaryAction: $Exports< + "material-ui/List/ListItemSecondaryAction" + >; + declare export var ListItemText: $Exports<"material-ui/List/ListItemText">; + declare export var ListSubheader: $Exports<"material-ui/List/ListSubheader">; + declare export var Menu: $Exports<"material-ui/Menu/Menu">; + declare export var MenuItem: $Exports<"material-ui/Menu/MenuItem">; + declare export var MenuList: $Exports<"material-ui/Menu/MenuList">; + declare export var MobileStepper: $Exports< + "material-ui/MobileStepper/MobileStepper" + >; + declare export var Modal: $Exports<"material-ui/Modal/Modal">; + declare export var Backdrop: $Exports<"material-ui/Modal/Backdrop">; + declare export var ModalManager: $Exports<"material-ui/Modal/ModalManager">; + declare export var Paper: $Exports<"material-ui/Paper/Paper">; + declare export var Popover: $Exports<"material-ui/Popover/Popover">; + declare export var Portal: $Exports<"material-ui/Portal/Portal">; + declare export var CircularProgress: $Exports< + "material-ui/Progress/CircularProgress" + >; + declare export var LinearProgress: $Exports< + "material-ui/Progress/LinearProgress" + >; + declare export var Radio: $Exports<"material-ui/Radio/Radio">; + declare export var RadioGroup: $Exports<"material-ui/Radio/RadioGroup">; + declare export var Select: $Exports<"material-ui/Select/Select">; + declare export var Snackbar: $Exports<"material-ui/Snackbar/Snackbar">; + declare export var SnackbarContent: $Exports< + "material-ui/Snackbar/SnackbarContent" + >; + declare export var Stepper: $Exports<"material-ui/Stepper/Stepper">; + declare export var Step: $Exports<"material-ui/Stepper/Step">; + declare export var StepButton: $Exports<"material-ui/Stepper/StepButton">; + declare export var StepIcon: $Exports<"material-ui/Stepper/StepIcon">; + declare export var StepContent: $Exports<"material-ui/Stepper/StepContent">; + declare export var StepLabel: $Exports<"material-ui/Stepper/StepLabel">; + declare export var MuiThemeProvider: $Exports< + "material-ui/styles/MuiThemeProvider" + >; + declare export var withStyles: $Exports<"material-ui/styles/withStyles">; + declare export var withTheme: $Exports<"material-ui/styles/withTheme">; + declare export var createMuiTheme: $Exports< + "material-ui/styles/createMuiTheme" + >; + declare export var jssPreset: $Exports<"material-ui/styles/jssPreset">; + declare export var SvgIcon: $Exports<"material-ui/SvgIcon/SvgIcon">; + declare export var SwipeableDrawer: $Exports<"material-ui/SwipeableDrawer">; + declare export var Switch: $Exports<"material-ui/Switch/Switch">; + declare export var Table: $Exports<"material-ui/Table/Table">; + declare export var TableBody: $Exports<"material-ui/Table/TableBody">; + declare export var TableCell: $Exports<"material-ui/Table/TableCell">; + declare export var TableFooter: $Exports<"material-ui/Table/TableFooter">; + declare export var TableHead: $Exports<"material-ui/Table/TableHead">; + declare export var TablePagination: $Exports< + "material-ui/Table/TablePagination" + >; + declare export var TableRow: $Exports<"material-ui/Table/TableRow">; + declare export var TableSortLabel: $Exports< + "material-ui/Table/TableSortLabel" + >; + declare export var Tabs: $Exports<"material-ui/Tabs/Tab">; + declare export var Tab: $Exports<"material-ui/Tabs/Tab">; + declare export var Typography: $Exports<"material-ui/Typography/Typography">; + declare export var TextField: $Exports<"material-ui/TextField/TextField">; + declare export var Toolbar: $Exports<"material-ui/Toolbar/Toolbar">; + declare export var Tooltip: $Exports<"material-ui/Tooltip/Tooltip">; + declare export var Slide: $Exports<"material-ui/transitions/Slide">; + declare export var Grow: $Exports<"material-ui/transitions/Grow">; + declare export var Fade: $Exports<"material-ui/transitions/Fade">; + declare export var Collapse: $Exports<"material-ui/transitions/Collapse">; + declare export var Zoom: $Exports<"material-ui/transitions/Zoom">; + + declare export var withWidth: $Exports<"material-ui/utils/withWidth">; + declare export var common: $Exports<"material-ui/colors/common">; + declare export var red: $Exports<"material-ui/colors/red">; + declare export var pink: $Exports<"material-ui/colors/pink">; + declare export var purple: $Exports<"material-ui/colors/purple">; + declare export var deepPurple: $Exports<"material-ui/colors/deepPurple">; + declare export var indigo: $Exports<"material-ui/colors/indigo">; + declare export var blue: $Exports<"material-ui/colors/blue">; + declare export var lightBlue: $Exports<"material-ui/colors/lightBlue">; + declare export var cyan: $Exports<"material-ui/colors/cyan">; + declare export var teal: $Exports<"material-ui/colors/teal">; + declare export var green: $Exports<"material-ui/colors/green">; + declare export var lightGreen: $Exports<"material-ui/colors/lightGreen">; + declare export var lime: $Exports<"material-ui/colors/lime">; + declare export var yellow: $Exports<"material-ui/colors/yellow">; + declare export var amber: $Exports<"material-ui/colors/amber">; + declare export var orange: $Exports<"material-ui/colors/orange">; + declare export var deepOrange: $Exports<"material-ui/colors/deepOrange">; + declare export var brown: $Exports<"material-ui/colors/brown">; + declare export var grey: $Exports<"material-ui/colors/grey">; + declare export var blueGrey: $Exports<"material-ui/colors/blueGrey">; +} diff --git a/definitions/npm/material-ui_v1.x.x/test_all_imports_material-ui_v1.x.x.js b/definitions/npm/material-ui_v1.x.x/test_all_imports_material-ui_v1.x.x.js new file mode 100644 index 0000000000..a34c5dba1e --- /dev/null +++ b/definitions/npm/material-ui_v1.x.x/test_all_imports_material-ui_v1.x.x.js @@ -0,0 +1,107 @@ +// @flow + +import React from "react"; + +import { + AppBar, + Avatar, + Badge, + BottomNavigation, + BottomNavigationAction, + Button, + ButtonBase, + Card, + CardActions, + CardContent, + CardHeader, + CardMedia, + Checkbox, + Chip, + ClickAwayListener, + CssBaseline, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + withMobileDialog, + Divider, + Drawer, + ExpansionPanel, + ExpansionPanelActions, + ExpansionPanelDetails, + ExpansionPanelSummary, + FormControl, + FormGroup, + FormLabel, + FormHelperText, + FormControlLabel, + Hidden, + Icon, + IconButton, + Input, + InputLabel, + InputAdornment, + Grid, + GridList, + GridListTile, + GridListTileBar, + List, + ListItem, + ListItemAvatar, + ListItemIcon, + ListItemSecondaryAction, + ListItemText, + ListSubheader, + Menu, + MenuItem, + MenuList, + MobileStepper, + Modal, + Backdrop, + ModalManager, + Paper, + Popover, + Portal, + CircularProgress, + LinearProgress, + Radio, + RadioGroup, + Select, + Snackbar, + SnackbarContent, + Stepper, + Step, + StepButton, + StepIcon, + StepContent, + StepLabel, + MuiThemeProvider, + withStyles, + withTheme, + createMuiTheme, + jssPreset, + SvgIcon, + SwipeableDrawer, + Switch, + Table, + TableBody, + TableCell, + TableFooter, + TableHead, + TablePagination, + TableRow, + TableSortLabel, + Tabs, + Tab, + Typography, + TextField, + Toolbar, + Tooltip, + Slide, + Grow, + Fade, + Collapse, + Zoom, + withWidth +} from "material-ui"; diff --git a/definitions/npm/material-ui_v1.x.x/test_module_imports_material-ui_v1.x.x.js b/definitions/npm/material-ui_v1.x.x/test_module_imports_material-ui_v1.x.x.js new file mode 100644 index 0000000000..ad8a16853b --- /dev/null +++ b/definitions/npm/material-ui_v1.x.x/test_module_imports_material-ui_v1.x.x.js @@ -0,0 +1,103 @@ +// @flow + +import React from "react"; + +import AppBar from "material-ui/AppBar"; +import Avatar from "material-ui/Avatar"; +import Badge from "material-ui/Badge"; +import BottomNavigation, { + BottomNavigationAction +} from "material-ui/BottomNavigation"; +import Button from "material-ui/Button"; +import ButtonBase from "material-ui/ButtonBase"; +import Card, { + CardActions, + CardContent, + CardHeader, + CardMedia +} from "material-ui/Card"; +import Checkbox from "material-ui/Checkbox"; +import Chip from "material-ui/Chip"; +import ClickAwayListener from "material-ui/utils/ClickAwayListener"; +import CssBaseline from "material-ui/CssBaseline"; +import Dialog, { + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + withMobileDialog +} from "material-ui/Dialog"; +import Divider from "material-ui/Divider"; +import Drawer from "material-ui/Drawer"; +import ExpansionPanel, { + ExpansionPanelActions, + ExpansionPanelDetails, + ExpansionPanelSummary +} from "material-ui/ExpansionPanel"; +import { + FormControl, + FormGroup, + FormLabel, + FormHelperText, + FormControlLabel +} from "material-ui/Form"; +import Hidden from "material-ui/Hidden"; +import Icon from "material-ui/Icon"; +import IconButton from "material-ui/IconButton"; +import Input, { InputLabel, InputAdornment } from "material-ui/Input"; +import Grid from "material-ui/Grid"; +import GridList, { GridListTile, GridListTileBar } from "material-ui/GridList"; + +import List, { + ListItem, + ListItemAvatar, + ListItemIcon, + ListItemSecondaryAction, + ListItemText, + ListSubheader +} from "material-ui/List"; +import Menu, { MenuItem, MenuList } from "material-ui/Menu"; +import MobileStepper from "material-ui/MobileStepper"; +import Modal, { Backdrop, ModalManager } from "material-ui/Modal"; +import Paper from "material-ui/Paper"; +import Popover from "material-ui/Popover"; +import Portal from "material-ui/Portal"; +import { CircularProgress, LinearProgress } from "material-ui/Progress"; +import Radio, { RadioGroup } from "material-ui/Radio"; +import Select from "material-ui/Select"; +import Snackbar, { SnackbarContent } from "material-ui/Snackbar"; +import Stepper, { + Step, + StepButton, + StepIcon, + StepContent, + StepLabel +} from "material-ui/Stepper"; +import { + MuiThemeProvider, + withStyles, + withTheme, + createMuiTheme, + jssPreset +} from "material-ui/styles"; + +import SvgIcon from "material-ui/SvgIcon"; +import SwipeableDrawer from "material-ui/SwipeableDrawer"; +import Switch from "material-ui/Switch"; +import Table, { + TableBody, + TableCell, + TableFooter, + TableHead, + TablePagination, + TableRow, + TableSortLabel +} from "material-ui/Table"; +import Tabs, { Tab } from "material-ui/Tabs"; +import Typography from "material-ui/Typography"; +import TextField from "material-ui/TextField"; +import Toolbar from "material-ui/Toolbar"; +import Tooltip from "material-ui/Tooltip"; +import { Slide, Grow, Fade, Collapse, Zoom } from "material-ui/transitions"; + +import withWidth from "material-ui/utils/withWidth"; From c25453d9deeb7fd31c365824b27304c93b3a6555 Mon Sep 17 00:00:00 2001 From: Justin Shepard Date: Tue, 3 Apr 2018 16:17:08 -0700 Subject: [PATCH 56/75] Adding libdef for Winston Logging Package (#2013) * Adding libdef for Winston Logging Package Added a libdef and test for the winston logging package. * Address Review Comments Ran prettier over both new files. Replaced 'require("winston")' with import. Moved libdef from flow_all to flow_v0.34.x- directory, which was the earliest version of flow I tested that worked. --- .../flow_v0.34.x-/winston_v3.x.x.js | 82 +++++++++++++++++++ .../npm/winston_v3.x.x/test_winston_v3.x.x.js | 54 ++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 definitions/npm/winston_v3.x.x/flow_v0.34.x-/winston_v3.x.x.js create mode 100644 definitions/npm/winston_v3.x.x/test_winston_v3.x.x.js diff --git a/definitions/npm/winston_v3.x.x/flow_v0.34.x-/winston_v3.x.x.js b/definitions/npm/winston_v3.x.x/flow_v0.34.x-/winston_v3.x.x.js new file mode 100644 index 0000000000..3f260a2133 --- /dev/null +++ b/definitions/npm/winston_v3.x.x/flow_v0.34.x-/winston_v3.x.x.js @@ -0,0 +1,82 @@ +declare type $winstonLevels = { + [string]: number +}; + +declare type $winstonNpmLogLevels = { + error: number, + warn: number, + info: number, + verbose: number, + debug: number, + silly: number +}; + +declare type $winstonInfo = { + level: $Keys, + message: string +}; + +declare type $winstonFormat = Object; + +declare type $winstonFileTransportConfig = { + filename: string, + level?: $Keys +}; + +declare class $winstonTransport {} + +declare class $winstonFileTransport extends $winstonTransport { + constructor($winstonFileTransportConfig): $winstonFileTransport; +} + +declare type $winstonConsoleTransportConfig = { + level?: $Keys +}; + +declare class $winstonConsoleTransport extends $winstonTransport { + constructor( + config?: $winstonConsoleTransportConfig + ): $winstonConsoleTransport; +} + +declare type $winstonLoggerConfig = { + exitOnError?: boolean, + format?: $winstonFormat, + level?: $Keys, + levels?: T, + transports?: Array<$winstonTransport> +}; + +declare type $winstonLogger = { + [$Keys]: (message: string) => void, + add: $winstonTransport => void, + clear: () => void, + configure: ($winstonLoggerConfig) => void, + log: (message: $winstonInfo) => void, + remove: $winstonTransport => void +}; + +declare type $winstonConfigSubModule = { + npm: () => $winstonNpmLogLevels +}; + +declare type $winstonFormatSubModule = { + combine: (...args: Array<$winstonFormat>) => $winstonFormat, + json: () => $winstonFormat, + prettyPrint: () => $winstonFormat, + simple: () => $winstonFormat, + timestamp: () => $winstonFormat +}; + +declare type $winstonDefaultLogger = $winstonLogger<$winstonNpmLogLevels>; + +declare module "winston" { + declare module.exports: $winstonDefaultLogger & { + format: $winstonFormatSubModule, + transports: { + Console: typeof $winstonConsoleTransport, + File: typeof $winstonFileTransport + }, + createLogger: ($winstonLoggerConfig) => $winstonLogger + }; +} diff --git a/definitions/npm/winston_v3.x.x/test_winston_v3.x.x.js b/definitions/npm/winston_v3.x.x/test_winston_v3.x.x.js new file mode 100644 index 0000000000..5fe79b6666 --- /dev/null +++ b/definitions/npm/winston_v3.x.x/test_winston_v3.x.x.js @@ -0,0 +1,54 @@ +import winston from "winston"; + +winston.log({ + level: "info", + message: "default logger info message" +}); +winston.error("default logger error message"); + +let logger = winston.createLogger({ + format: winston.format.json(), + level: "debug", + exitOnError: false, + transports: [ + new winston.transports.File({ filename: "error.log", level: "error" }), + new winston.transports.Console({ + format: winston.format.combine( + winston.format.timestamp(), + winston.format.simple() + ) + }) + ] +}); +logger.info("info message"); +logger.error("error message"); +logger.log({ + level: "debug", + message: "debug message" +}); + +logger.clear(); + +const consoleTransport = new winston.transports.Console(); +logger.add(consoleTransport); +logger.remove(consoleTransport); + +logger.configure({ + level: "error" +}); +logger.warn("warn message"); + +// $ExpectError +logger = winston.createLogger({ + format: winston.format.prettyPrint(), + level: "foo", + levels: { + foo: 0, + bar: 1, + baz: 2 + }, + transports: [new winston.transports.Console()] +}); +logger.foo("foo message"); +logger.bar("bar message"); +logger.info("info message"); From 1494e2ff8559c859b9aa41fea7bcbd723eb5605a Mon Sep 17 00:00:00 2001 From: Ole Christian Eidheim Date: Wed, 4 Apr 2018 01:17:37 +0200 Subject: [PATCH 57/75] Added libdef for @nx-js/observer-util (#2011) * Added libdef for @nx-js/observer-util * Renamed observer_util in paths to observer-util --- .../flow_v0.25.x-/observer-util_v4.x.x.js | 19 +++++++++++++++++++ .../test_observer-util_v4.x.x.js | 14 ++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 definitions/npm/@nx-js/observer-util_v4.x.x/flow_v0.25.x-/observer-util_v4.x.x.js create mode 100644 definitions/npm/@nx-js/observer-util_v4.x.x/test_observer-util_v4.x.x.js diff --git a/definitions/npm/@nx-js/observer-util_v4.x.x/flow_v0.25.x-/observer-util_v4.x.x.js b/definitions/npm/@nx-js/observer-util_v4.x.x/flow_v0.25.x-/observer-util_v4.x.x.js new file mode 100644 index 0000000000..8389fb9468 --- /dev/null +++ b/definitions/npm/@nx-js/observer-util_v4.x.x/flow_v0.25.x-/observer-util_v4.x.x.js @@ -0,0 +1,19 @@ +declare module '@nx-js/observer-util' { + declare function observable(obj?: Observable): Observable; + declare function isObservable(obj: Object): boolean; + declare function raw(obj: Observable): Observable; + + declare type Scheduler = { + add: Function, + delete: Function + }; + + declare type ObserveOptions = { + scheduler?: Scheduler | Function, + debugger?: Function, + lazy?: boolean + } + + declare function observe(func: Reaction, options?: ObserveOptions): Reaction; + declare function unobserve(func: Function): void; +} diff --git a/definitions/npm/@nx-js/observer-util_v4.x.x/test_observer-util_v4.x.x.js b/definitions/npm/@nx-js/observer-util_v4.x.x/test_observer-util_v4.x.x.js new file mode 100644 index 0000000000..0292bcd3f4 --- /dev/null +++ b/definitions/npm/@nx-js/observer-util_v4.x.x/test_observer-util_v4.x.x.js @@ -0,0 +1,14 @@ +// @flow + +import {observable, isObservable, observe, unobserve} from '@nx-js/observer-util'; + +const time = observable({seconds: 10}); +let check: boolean = isObservable(time); +const logger = observe(() => console.log(time.seconds)); +unobserve(logger); + +// $ExpectError +const errorLogger = observe(time); + +// $ExpectError +const errorTime = observable(2); From 5df2f01d218250041c133d15e3af929517380e11 Mon Sep 17 00:00:00 2001 From: Michael Hsu Date: Wed, 4 Apr 2018 13:56:35 +0800 Subject: [PATCH 58/75] fix(next-route): make customHandler optional (#1821) --- .../npm/next-routes_v1.x.x/flow_v0.47.x-/next-routes_v1.x.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/npm/next-routes_v1.x.x/flow_v0.47.x-/next-routes_v1.x.x.js b/definitions/npm/next-routes_v1.x.x/flow_v0.47.x-/next-routes_v1.x.x.js index 618f5f4e75..1942c2918b 100644 --- a/definitions/npm/next-routes_v1.x.x/flow_v0.47.x-/next-routes_v1.x.x.js +++ b/definitions/npm/next-routes_v1.x.x/flow_v0.47.x-/next-routes_v1.x.x.js @@ -79,7 +79,7 @@ declare module 'next-routes' { add(route: Route | string): Routes; add(pattern: string, page: string): Routes; add(name: string, pattern: string, page: string): Routes; - getRequestHandler(app: Object, customHandler: (any) => any): Function; + getRequestHandler(app: Object, customHandler?: (any) => any): Function; pushRoute( route: string, params?: { [name: string]: string }, From 8a23000dd1a7640045482da5f250fca0b60aedbd Mon Sep 17 00:00:00 2001 From: Ashoat Tevosyan Date: Wed, 4 Apr 2018 02:31:18 -0400 Subject: [PATCH 59/75] Update react-navigation libdef (#1925) * Update react-navigation libdef We maintain our libdef in our [repo](https://github.com/react-navigation/react-navigation/blob/master/flow/react-navigation.js), and we make updates to it there. This PR merges our version upstream. * Add CONTRIBUTING.md for react-navigation * Use react-navigation 1.x branch --- .../react-navigation_v1.x.x/CONTRIBUTING.md | 5 + .../flow_v0.60.x-/react-navigation_v1.x.x.js | 138 ++++++------------ 2 files changed, 53 insertions(+), 90 deletions(-) create mode 100644 definitions/npm/react-navigation_v1.x.x/CONTRIBUTING.md diff --git a/definitions/npm/react-navigation_v1.x.x/CONTRIBUTING.md b/definitions/npm/react-navigation_v1.x.x/CONTRIBUTING.md new file mode 100644 index 0000000000..f5f6c03c50 --- /dev/null +++ b/definitions/npm/react-navigation_v1.x.x/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing to the React Navigation Flow libdef + +Please do not make changes directly to the libdef file in `flow-typed` without first submitting a PR to the [libdef within the `react-navigation` repo](https://github.com/react-navigation/react-navigation/blob/master/flow/react-navigation.js). After your PR has been accepted in `react-navigation`, you can go ahead and submit a PR on `flow-typed`. + +We admittedly have a slightly unusual system for maintaing our Flow types. We used to host Flow types directly in-package, but that prevented us from simultaneously supporting multiple React Native versions. To enable that support, we've moved our libdef to `flow-typed`, but we still want to (1) have our CI typecheck the libdef against our example projects, and (2) review any changes to the libdef. diff --git a/definitions/npm/react-navigation_v1.x.x/flow_v0.60.x-/react-navigation_v1.x.x.js b/definitions/npm/react-navigation_v1.x.x/flow_v0.60.x-/react-navigation_v1.x.x.js index 898fc5e32d..4117df6c1b 100644 --- a/definitions/npm/react-navigation_v1.x.x/flow_v0.60.x-/react-navigation_v1.x.x.js +++ b/definitions/npm/react-navigation_v1.x.x/flow_v0.60.x-/react-navigation_v1.x.x.js @@ -48,6 +48,15 @@ declare module 'react-navigation' { // react-native/Libraries/Animated/src/nodes/AnimatedValue.js declare type AnimatedValue = Object; + declare type HeaderForceInset = { + horizontal?: string, + vertical?: string, + left?: string, + right?: string, + top?: string, + bottom?: string, + }; + /** * Next, all the type declarations */ @@ -71,25 +80,11 @@ declare module 'react-navigation' { key?: string, |}; - declare type DeprecatedNavigationNavigateAction = {| - type: 'Navigate', - routeName: string, - params?: NavigationParams, - - // The action to run inside the sub-router - action?: NavigationNavigateAction | DeprecatedNavigationNavigateAction, - |}; - declare export type NavigationBackAction = {| type: 'Navigation/BACK', key?: ?string, |}; - declare type DeprecatedNavigationBackAction = {| - type: 'Back', - key?: ?string, - |}; - declare export type NavigationSetParamsAction = {| type: 'Navigation/SET_PARAMS', @@ -100,26 +95,11 @@ declare module 'react-navigation' { params: NavigationParams, |}; - declare type DeprecatedNavigationSetParamsAction = {| - type: 'SetParams', - - // The key of the route where the params should be set - key: string, - - // The new params to merge into the existing route params - params: NavigationParams, - |}; - declare export type NavigationInitAction = {| type: 'Navigation/INIT', params?: NavigationParams, |}; - declare type DeprecatedNavigationInitAction = {| - type: 'Init', - params?: NavigationParams, - |}; - declare export type NavigationResetAction = {| type: 'Navigation/RESET', index: number, @@ -127,25 +107,11 @@ declare module 'react-navigation' { actions: Array, |}; - declare type DeprecatedNavigationResetAction = {| - type: 'Reset', - index: number, - key?: ?string, - actions: Array< - NavigationNavigateAction | DeprecatedNavigationNavigateAction - >, - |}; - declare export type NavigationUriAction = {| type: 'Navigation/URI', uri: string, |}; - declare type DeprecatedNavigationUriAction = {| - type: 'Uri', - uri: string, - |}; - declare export type NavigationReplaceAction = {| +type: 'Navigation/REPLACE', +key: string, @@ -181,17 +147,6 @@ declare module 'react-navigation' { | NavigationSetParamsAction | NavigationResetAction; - declare type DeprecatedNavigationAction = - | DeprecatedNavigationInitAction - | DeprecatedNavigationNavigateAction - | DeprecatedNavigationBackAction - | DeprecatedNavigationSetParamsAction - | DeprecatedNavigationResetAction; - - declare export type PossiblyDeprecatedNavigationAction = - | NavigationAction - | DeprecatedNavigationAction; - /** * NavigationState is a tree of routes for a single navigator, where each * child route may either be a NavigationScreenRoute or a @@ -332,10 +287,12 @@ declare module 'react-navigation' { navigationOptions?: ?NavigationScreenConfig, }; - declare export type NavigationRouteConfig = { - navigationOptions?: NavigationScreenConfig<*>, - path?: string, - } & NavigationScreenRouteConfig; + declare export type NavigationRouteConfig = + | NavigationComponent + | ({ + navigationOptions?: NavigationScreenConfig<*>, + path?: string, + } & NavigationScreenRouteConfig); declare export type NavigationScreenRouteConfig = | { @@ -378,6 +335,7 @@ declare module 'react-navigation' { declare export type NavigationStackScreenOptions = NavigationScreenOptions & { header?: ?(React$Node | (HeaderProps => React$Node)), + headerTransparent?: boolean, headerTitle?: string | React$Node | React$ElementType, headerTitleStyle?: AnimatedTextStyleProp, headerTitleAllowFontScaling?: boolean, @@ -390,6 +348,8 @@ declare module 'react-navigation' { headerPressColorAndroid?: string, headerRight?: React$Node, headerStyle?: ViewStyleProp, + headerForceInset?: HeaderForceInset, + headerBackground?: React$Node | React$ElementType, gesturesEnabled?: boolean, gestureResponseDistance?: { vertical?: number, horizontal?: number }, gestureDirection?: 'default' | 'inverted', @@ -405,6 +365,7 @@ declare module 'react-navigation' { declare export type NavigationStackViewConfig = {| mode?: 'card' | 'modal', headerMode?: HeaderMode, + headerTransitionPreset?: 'fade-in-place' | 'uikit', cardStyle?: ViewStyleProp, transitionConfig?: () => TransitionConfig, onTransitionStart?: () => void, @@ -416,6 +377,20 @@ declare module 'react-navigation' { ...NavigationStackRouterConfig, |}; + /** + * Switch Navigator + */ + + declare export type NavigationSwitchRouterConfig = {| + initialRouteName?: string, + initialRouteParams?: NavigationParams, + paths?: NavigationPathsConfig, + navigationOptions?: NavigationScreenConfig<*>, + order?: Array, + backBehavior?: 'none' | 'initialRoute', // defaults to `'none'` + resetOnBlur?: boolean, // defaults to `true` + |}; + /** * Tab Navigator */ @@ -427,7 +402,6 @@ declare module 'react-navigation' { navigationOptions?: NavigationScreenConfig<*>, // todo: type these as the real route names rather than 'string' order?: Array, - // Does the back button cause the router to switch to the initial tab backBehavior?: 'none' | 'initialRoute', // defaults `initialRoute` |}; @@ -476,7 +450,7 @@ declare module 'react-navigation' { */ declare export type NavigationDispatch = ( - action: PossiblyDeprecatedNavigationAction + action: NavigationAction ) => boolean; declare export type NavigationProp = { @@ -495,7 +469,7 @@ declare module 'react-navigation' { type: EventType, action: NavigationAction, state: NavigationState, - lastState: NavigationState, + lastState: ?NavigationState, }; declare export type NavigationEventCallback = ( @@ -540,29 +514,6 @@ declare module 'react-navigation' { navigationOptions?: O, }>; - //declare export type NavigationNavigatorProps = - // | {} - // | { navigation: NavigationScreenProp } - // | { screenProps: {} } - // | { navigationOptions: O } - // | { - // navigation: NavigationScreenProp, - // screenProps: {}, - // } - // | { - // navigation: NavigationScreenProp, - // navigationOptions: O, - // } - // | { - // screenProps: {}, - // navigationOptions: O, - // } - // | { - // navigation: NavigationScreenProp, - // screenProps: {}, - // navigationOptions: O, - // }; - /** * Navigation container */ @@ -783,9 +734,6 @@ declare module 'react-navigation' { (payload: { uri: string }): NavigationUriAction, toString: () => string, }, - mapDeprecatedActionAndWarn: ( - action: PossiblyDeprecatedNavigationAction - ) => NavigationAction, }; declare type _RouterProp = { @@ -837,6 +785,13 @@ declare module 'react-navigation' { routeConfigs: NavigationRouteConfigMap, config?: _TabNavigatorConfig ): NavigationContainer<*, *, *>; + declare type _SwitchNavigatorConfig = {| + ...NavigationSwitchRouterConfig, + |}; + declare export function SwitchNavigator( + routeConfigs: NavigationRouteConfigMap, + config?: _SwitchNavigatorConfig + ): NavigationContainer<*, *, *>; declare type _DrawerViewConfig = {| drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open', @@ -951,9 +906,9 @@ declare module 'react-navigation' { }; declare export var SafeAreaView: React$ComponentType<_SafeAreaViewProps>; - declare export class Header extends React$Component { - static HEIGHT: number - } + declare export var Header: React$ComponentType & { + HEIGHT: number, + }; declare type _HeaderTitleProps = { children: React$Node, @@ -1103,4 +1058,7 @@ declare module 'react-navigation' { declare export function withNavigation( Component: React$ComponentType ): React$ComponentType; + declare export function withNavigationFocus( + Component: React$ComponentType + ): React$ComponentType; } From 750ef58fb1e46c0460abe44dbc0227d69dcbc4f4 Mon Sep 17 00:00:00 2001 From: Ville Saukkonen Date: Wed, 4 Apr 2018 09:52:05 +0300 Subject: [PATCH 60/75] Cleanup runTests a bit (#1992) * move filtering flow versions to own function * move fetching and filtering out of while loop * map instead of forEach * get rid of side-effect based variable assigning * less indentation by flipping null check * move flow bin fetching out of runTestGroup --- cli/src/commands/runTests.js | 332 +++++++++++++++++------------------ 1 file changed, 165 insertions(+), 167 deletions(-) diff --git a/cli/src/commands/runTests.js b/cli/src/commands/runTests.js index 24fb242682..ea5daa8f88 100644 --- a/cli/src/commands/runTests.js +++ b/cli/src/commands/runTests.js @@ -95,175 +95,169 @@ let _flowBinVersionPromise = null; async function getOrderedFlowBinVersions( numberOfReleases: number = 15, ): Promise> { - if (_flowBinVersionPromise === null) { - _flowBinVersionPromise = (async function() { - console.log('Fetching all Flow binaries...'); - const IS_WINDOWS = os.type() === 'Windows_NT'; - const FLOW_BIN_VERSION_ORDER = []; - const GH_CLIENT = gitHubClient(); - // We only test against the latest numberOfReleases Versions - const QUERY_PAGE_SIZE = numberOfReleases; - const OS_ARCH_FILTER_RE = new RegExp(`flow-${BIN_PLATFORM}`); - - let binURLs = new Map(); - let apiPayload = null; - let page = 0; - while ( - apiPayload === null /* || apiPayload.length === QUERY_PAGE_SIZE*/ - ) { - apiPayload = await new Promise((res, rej) => { - GH_CLIENT.releases.listReleases( - { - owner: 'facebook', - repo: 'flow', - page: page++, - per_page: QUERY_PAGE_SIZE, - }, - (err, result) => { - if (err) { - rej(err); - } else { - res(result); - } - }, - ); - }); - - apiPayload.forEach(rel => { - // Temporary fix for https://github.com/facebook/flow/issues/5922 - if (rel.tag_name === 'v0.67.0') { - console.log( - '==========================================================================================', - ); - console.log( - 'We are tempoarily skipping v0.67.0 due to https://github.com/facebook/flow/issues/5922', - ); - console.log( - '==========================================================================================', - ); - return; - } - - // We only test against versions since 0.15.0 because it has proper - // [ignore] fixes (which are necessary to run tests) - // Because Windows was only supported starting with version 0.30.0, we also skip version prior to that when running on windows. - if (semver.lt(rel.tag_name, IS_WINDOWS ? '0.30.0' : '0.15.0')) { - return; - } - // Because flow 0.57 was broken before 0.57.3 on the Windows platform, we also skip those versions when running on windows. - if ( - IS_WINDOWS && - (semver.eq(rel.tag_name, '0.57.0') || - semver.eq(rel.tag_name, '0.57.1') || - semver.eq(rel.tag_name, '0.57.2')) - ) { - return; + if (_flowBinVersionPromise !== null) { + return _flowBinVersionPromise; + } + return (_flowBinVersionPromise = (async function() { + console.log('Fetching all Flow binaries...'); + const IS_WINDOWS = os.type() === 'Windows_NT'; + const GH_CLIENT = gitHubClient(); + // We only test against the latest numberOfReleases Versions + const QUERY_PAGE_SIZE = numberOfReleases; + const OS_ARCH_FILTER_RE = new RegExp(`flow-${BIN_PLATFORM}`); + + let page = 0; + const apiPayload = await new Promise((res, rej) => { + GH_CLIENT.releases.listReleases( + { + owner: 'facebook', + repo: 'flow', + page: page++, + per_page: QUERY_PAGE_SIZE, + }, + (err, result) => { + if (err) { + rej(err); + } else { + res(result); } + }, + ); + }); - // Find the binary zip in the list of assets - const binZip = rel.assets - .filter(({name}) => { - return OS_ARCH_FILTER_RE.test(name) && !/-latest.zip$/.test(name); - }) - .map(asset => asset.browser_download_url); - - if (binZip.length !== 1) { - throw new Error( - 'Unexpected number of ' + - BIN_PLATFORM + - ' assets for flow-' + - rel.tag_name + - '! ' + - JSON.stringify(binZip), - ); - } else { - const version = - rel.tag_name[0] === 'v' ? rel.tag_name : 'v' + rel.tag_name; + const flowBins = apiPayload + .filter(rel => { + // Temporary fix for https://github.com/facebook/flow/issues/5922 + if (rel.tag_name === 'v0.67.0') { + console.log( + '==========================================================================================', + ); + console.log( + 'We are tempoarily skipping v0.67.0 due to https://github.com/facebook/flow/issues/5922', + ); + console.log( + '==========================================================================================', + ); + return false; + } - FLOW_BIN_VERSION_ORDER.push(version); - binURLs.set(version, binZip[0]); - } - }); - } + // We only test against versions since 0.15.0 because it has proper + // [ignore] fixes (which are necessary to run tests) + // Because Windows was only supported starting with version 0.30.0, we also skip version prior to that when running on windows. + if (semver.lt(rel.tag_name, IS_WINDOWS ? '0.30.0' : '0.15.0')) { + return false; + } - FLOW_BIN_VERSION_ORDER.sort((a, b) => { - return semver.lt(a, b) ? -1 : 1; + // Because flow 0.57 was broken before 0.57.3 on the Windows platform, we also skip those versions when running on windows. + if ( + IS_WINDOWS && + (semver.eq(rel.tag_name, '0.57.0') || + semver.eq(rel.tag_name, '0.57.1') || + semver.eq(rel.tag_name, '0.57.2')) + ) { + return false; + } + return true; + }) + .map(rel => { + // Find the binary zip in the list of assets + const binZip = rel.assets + .filter(({name}) => { + return OS_ARCH_FILTER_RE.test(name) && !/-latest.zip$/.test(name); + }) + .map(asset => asset.browser_download_url); + + if (binZip.length !== 1) { + throw new Error( + 'Unexpected number of ' + + BIN_PLATFORM + + ' assets for flow-' + + rel.tag_name + + '! ' + + JSON.stringify(binZip), + ); + } else { + const version = + rel.tag_name[0] === 'v' ? rel.tag_name : 'v' + rel.tag_name; + return {version, binURL: binZip[0]}; + } + }) + .sort((a, b) => { + return semver.lt(a.version, b.version) ? -1 : 1; }); - await P.all( - Array.from(binURLs).map(async ([version, binURL]) => { - const zipPath = path.join(BIN_DIR, 'flow-' + version + '.zip'); - const binPath = path.join( - BIN_DIR, - 'flow-' + version + (IS_WINDOWS ? '.exe' : ''), - ); + await P.all( + flowBins.map(async ({version, binURL}) => { + const zipPath = path.join(BIN_DIR, 'flow-' + version + '.zip'); + const binPath = path.join( + BIN_DIR, + 'flow-' + version + (IS_WINDOWS ? '.exe' : ''), + ); - if (await fs.exists(binPath)) { - return; - } + if (await fs.exists(binPath)) { + return; + } - // Download the zip file - await new Promise((res, rej) => { - console.log(' Fetching flow-%s...', version); - got - .stream(binURL, { - headers: { - 'User-Agent': - 'flow-typed Test Runner ' + - '(github.com/flowtype/flow-typed)', - }, - }) - .on('error', err => rej(err)) - .pipe( - fs.createWriteStream(zipPath).on('close', () => { - console.log(' flow-%s finished downloading.', version); - res(); - }), - ); - }); + // Download the zip file + await new Promise((res, rej) => { + console.log(' Fetching flow-%s...', version); + got + .stream(binURL, { + headers: { + 'User-Agent': + 'flow-typed Test Runner ' + + '(github.com/flowtype/flow-typed)', + }, + }) + .on('error', err => rej(err)) + .pipe( + fs.createWriteStream(zipPath).on('close', () => { + console.log(' flow-%s finished downloading.', version); + res(); + }), + ); + }); - // Extract the flow binary - const flowBinDirPath = path.join(BIN_DIR, 'TMP-flow-' + version); - await fs.mkdir(flowBinDirPath); - console.log(' Extracting flow-%s...', version); - await new Promise((res, rej) => { - const unzipExtractor = unzip.Extract({path: flowBinDirPath}); - unzipExtractor.on('error', function(err) { - rej(err); - }); - unzipExtractor.on('close', function() { - res(); - }); - fs.createReadStream(zipPath).pipe(unzipExtractor); + // Extract the flow binary + const flowBinDirPath = path.join(BIN_DIR, 'TMP-flow-' + version); + await fs.mkdir(flowBinDirPath); + console.log(' Extracting flow-%s...', version); + await new Promise((res, rej) => { + const unzipExtractor = unzip.Extract({path: flowBinDirPath}); + unzipExtractor.on('error', function(err) { + rej(err); }); - if (IS_WINDOWS) { - await fs.rename( - path.join(flowBinDirPath, 'flow', 'flow.exe'), - path.join(BIN_DIR, 'flow-' + version + '.exe'), - ); - } else { - await fs.rename( - path.join(flowBinDirPath, 'flow', 'flow'), - path.join(BIN_DIR, 'flow-' + version), - ); + unzipExtractor.on('close', function() { + res(); + }); + fs.createReadStream(zipPath).pipe(unzipExtractor); + }); + if (IS_WINDOWS) { + await fs.rename( + path.join(flowBinDirPath, 'flow', 'flow.exe'), + path.join(BIN_DIR, 'flow-' + version + '.exe'), + ); + } else { + await fs.rename( + path.join(flowBinDirPath, 'flow', 'flow'), + path.join(BIN_DIR, 'flow-' + version), + ); - await child_process.execP( - ['chmod', '755', path.join(BIN_DIR, 'flow-' + version)].join(' '), - ); - } + await child_process.execP( + ['chmod', '755', path.join(BIN_DIR, 'flow-' + version)].join(' '), + ); + } - console.log(' Removing flow-%s artifacts...', version); - await P.all([recursiveRmdir(flowBinDirPath), fs.unlink(zipPath)]); - console.log(' flow-%s complete!', version); - }), - ); + console.log(' Removing flow-%s artifacts...', version); + await P.all([recursiveRmdir(flowBinDirPath), fs.unlink(zipPath)]); + console.log(' flow-%s complete!', version); + }), + ); - console.log('Finished fetching Flow binaries.\n'); + console.log('Finished fetching Flow binaries.\n'); - return FLOW_BIN_VERSION_ORDER; - })(); - } - return _flowBinVersionPromise; + return flowBins.map(bin => bin.version); + })()); } const flowNameRegex = /^flow-v[0-9]+.[0-9]+.[0-9]+(\.exe)?$/; @@ -477,9 +471,9 @@ async function removeTrashFromBinDir() { async function runTestGroup( repoDirPath: string, testGroup: TestGroup, - numberOfFlowVersions: number = 15, - errors = [], + orderedFlowVersions: Array, ): Promise> { + const errors = []; // Some older versions of Flow choke on ">"/"<"/"=" const testDirName = testGroup.id .replace(/\//g, '--') @@ -499,15 +493,6 @@ async function runTestGroup( await fs.mkdir(BIN_DIR); } - //Prepare bin folder to collect flow instances - await removeTrashFromBinDir(); - let orderedFlowVersions; - try { - orderedFlowVersions = await getOrderedFlowBinVersions(numberOfFlowVersions); - } catch (e) { - orderedFlowVersions = await getCachedFlowBinVersions(numberOfFlowVersions); - } - try { await fs.mkdir(testDirPath); @@ -635,10 +620,23 @@ async function runTests( const results = new Map(); while (testGroups.length > 0) { const testGroup = testGroups.shift(); + //Prepare bin folder to collect flow instances + await removeTrashFromBinDir(); + let orderedFlowVersions; + try { + orderedFlowVersions = await getOrderedFlowBinVersions( + numberOfFlowVersions, + ); + } catch (e) { + orderedFlowVersions = await getCachedFlowBinVersions( + numberOfFlowVersions, + ); + } + const testGroupErrors = await runTestGroup( repoDirPath, testGroup, - numberOfFlowVersions, + orderedFlowVersions, ); if (testGroupErrors.length > 0) { const errors = results.get(testGroup.id) || []; From ab9a73e70c2bcab7fd78c3a32b72e4180f8842aa Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Lira Date: Wed, 4 Apr 2018 08:53:18 +0200 Subject: [PATCH 61/75] Add mockName type to jest mocked functions (#1998) * Add mockName type to jest mocked functions * Add test for jest's mockName * Add mockName definition under cli/flow-typed/npm --- cli/flow-typed/npm/jest_v22.x.x.js | 5 +++++ .../npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js | 5 +++++ definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js | 5 +++++ .../npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/cli/flow-typed/npm/jest_v22.x.x.js b/cli/flow-typed/npm/jest_v22.x.x.js index 8d1c4aaa14..8c9f7d045f 100644 --- a/cli/flow-typed/npm/jest_v22.x.x.js +++ b/cli/flow-typed/npm/jest_v22.x.x.js @@ -55,6 +55,11 @@ type JestMockFn, TReturn> = { mockImplementationOnce( fn: (...args: TArguments) => TReturn, ): JestMockFn, + /** + * Accepts a string to use in test result output in place of "jest.fn()" to + * indicate which mock function is being referenced. + */ + mockName(name: string): JestMockFn < TArguments, TReturn >, /** * Just a simple sugar function for returning `this` */ diff --git a/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js index f0a635624e..9a2e4d56ec 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.25.x-v0.38.x/jest_v22.x.x.js @@ -48,6 +48,11 @@ type JestMockFn = { * calls produce different results. */ mockImplementationOnce(fn: Function): JestMockFn, + /** + * Accepts a string to use in test result output in place of "jest.fn()" to + * indicate which mock function is being referenced. + */ + mockName(name: string): JestMockFn, /** * Just a simple sugar function for returning `this` */ diff --git a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js index 7fc5476fe4..ccaaf1f54d 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/jest_v22.x.x.js @@ -52,6 +52,11 @@ type JestMockFn, TReturn> = { mockImplementationOnce( fn: (...args: TArguments) => TReturn ): JestMockFn, + /** + * Accepts a string to use in test result output in place of "jest.fn()" to + * indicate which mock function is being referenced. + */ + mockName(name: string): JestMockFn, /** * Just a simple sugar function for returning `this` */ diff --git a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js index 19e4e491b0..6c79d553e8 100644 --- a/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js +++ b/definitions/npm/jest_v22.x.x/flow_v0.39.x-/test_jest-v22.x.x.js @@ -44,6 +44,10 @@ foo.doStuff = jest.fn().mockReturnValueOnce(10); // $ExpectError Mock function expected to return number, not string. foo.doStuff = jest.fn().mockReturnValueOnce("10"); +foo.doStuff = jest.fn().mockName("10"); +// $ExpectError mockName expects a string, not a number +foo.doStuff = jest.fn().mockName(10); + const mockedDoStuff = (foo.doStuff = jest.fn().mockImplementation(str => 10)); mockedDoStuff.mock.calls[0][0].indexOf("a"); // $ExpectError function `doesntExist` not found in string. From 18b77b0f2e00a6ef8990345a1f181e490d856cdc Mon Sep 17 00:00:00 2001 From: devalon Date: Thu, 5 Apr 2018 16:52:12 +0900 Subject: [PATCH 62/75] Support stateless in react css modules (#2019) * Support stateless functional component style in `react-css-modules` * Fix test code * Fix to remove maybe type * Refactor test code by flow-typed-test module * Fix typo --- .../flow_v0.53.x-/react-css-modules_v3.x.x.js | 7 +- .../test_react-css-modules-v3.js | 108 +++++++++++++----- 2 files changed, 82 insertions(+), 33 deletions(-) diff --git a/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/react-css-modules_v3.x.x.js b/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/react-css-modules_v3.x.x.js index b88fabaab9..430af63af6 100644 --- a/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/react-css-modules_v3.x.x.js +++ b/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/react-css-modules_v3.x.x.js @@ -2,12 +2,13 @@ import React from "react"; declare module "react-css-modules" { + declare type StatelessComponent = (props: P, state: S) => React$Element; declare module.exports: , X>( - component: Class, + component: Class | StatelessComponent, styles: X, options?: {| allowMultiple?: boolean, - errorWhenNotFound?: boolean - |} + errorWhenNotFound?: boolean, + |}, ) => Class, S>>; } diff --git a/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/test_react-css-modules-v3.js b/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/test_react-css-modules-v3.js index 08927f081b..8495adca0f 100644 --- a/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/test_react-css-modules-v3.js +++ b/definitions/npm/react-css-modules_v3.x.x/flow_v0.53.x-/test_react-css-modules-v3.js @@ -2,42 +2,90 @@ import React, { Component } from 'react'; import CSSModules from 'react-css-modules'; +import { describe, it } from 'flow-typed-test'; -const styles = { test: '123' }; +describe('React Component', () => { + const styles = { test: '123' }; -class ExampleModule extends Component<{ - foo: string, - styles: typeof styles, -}> { - render() { - return
{this.props.foo}
; + class ExampleModule extends Component<{ + foo: string, + styles: typeof styles, + }> { + render() { + return
{this.props.foo}
; + } } -} + + it('React Component can be declared', () => { + const ExampleCSSModules = CSSModules(ExampleModule, styles); + const ExampleCSSModules2 = CSSModules(ExampleModule, styles, { allowMultiple: true }); + class Working extends Component<{}> { + render() { + return ; + } + } + }); + + it('React Component can be undeclared', () => { + const ExampleCSSModules = CSSModules(ExampleModule, styles); + // $ExpectError invalid module option. + const BustedCSSModule = CSSModules(ExampleModule, styles, { wubbaLubba: 'dub-dub' }); + + class Failure1 extends Component<{}> { + render() { + + // $ExpectError Missing prop `foo` will be caught. + return ; + } + } + + class Failure2 extends Component<{}> { + render() { + + // $ExpectError Unwrapped component won't be passed `styles`. + return ; + } + } + }); +}); -const ExampleCSSModules = CSSModules(ExampleModule, styles); -const ExampleCSSModules2 = CSSModules(ExampleModule, styles, { allowMultiple: true }); +describe('Stateless Functional Component', () => { + const styles = { test: '123' }; + type Props = { + foo: string, + styles: typeof styles, + }; + type State = {}; -// $ExpectError invalid module option. -const BustedCSSModule = CSSModules(ExampleModule, styles, { wubbaLubba: 'dub-dub' }); -1 -class Failure1 extends Component<{}> { - render() { - - // $ExpectError Missing prop `foo` will be caught. - return ; + // Props and State + const StatelessComponent = (props: Props, state: State) => { + return (
hoge
) + } + // Props only + const StatelessComponentPropsOnly = (props: Props) => { + return (
hoge
) } -} -class Failure2 extends Component<{}> { - render() { + it('Stateless Functional Component can be declared', () => { + const StatelessCSSComponent = CSSModules(StatelessComponent, styles); + CSSModules(StatelessComponent, styles, { allowMultiple: true }); + CSSModules(StatelessComponentPropsOnly, styles); + CSSModules(StatelessComponentPropsOnly, styles, { allowMultiple: true }); - // $ExpectError Unwrapped component won't be passed `styles`. - return ; - } -} + class Working extends Component<{}> { + render() { + return ; + } + } + }); + + it('Stateless Functional Component can be undeclared', () => { + class Failure extends Component<{}> { + render() { + // $ExpectError Unwrapped component won't be passed `styles`. + return ; + } + } + }); +}); -class Working extends Component<{}> { - render() { - return ; - } -} From 15b5072ad2408781ee325c01e1fc3941f211fdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Voto=C4=8Dek?= Date: Thu, 5 Apr 2018 19:36:38 +0200 Subject: [PATCH 63/75] update promise-retry (#2029) --- .../flow_v0.45.x-/promise-retry_v1.1.x.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/definitions/npm/promise-retry_v1.1.x/flow_v0.45.x-/promise-retry_v1.1.x.js b/definitions/npm/promise-retry_v1.1.x/flow_v0.45.x-/promise-retry_v1.1.x.js index 58220d3c58..af2a20f02d 100644 --- a/definitions/npm/promise-retry_v1.1.x/flow_v0.45.x-/promise-retry_v1.1.x.js +++ b/definitions/npm/promise-retry_v1.1.x/flow_v0.45.x-/promise-retry_v1.1.x.js @@ -1,4 +1,4 @@ -type RetryFn = (err: Error) => void; +type RetryFn = (err?: Error) => void; type Options = {| retries?: number, factor?: number, @@ -8,6 +8,8 @@ type Options = {| |}; declare module 'promise-retry' { + declare export type RetryOptions = Options; + declare module.exports: ( handler: (retry: RetryFn, retryNumber: Number) => Promise, options?: Options From 5e9c9fb73fc2da118d08d34fe55e48672415e79d Mon Sep 17 00:00:00 2001 From: Aaron Black Date: Thu, 5 Apr 2018 13:40:22 -0400 Subject: [PATCH 64/75] add puppeteer v1.2.x definitions (#2037) * add puppeteer v1.2.x definitions * add link to typescript definitions adapted from --- .../flow_v0.58.x-/puppeteer_v1.2.x.js | 1472 +++++++++++++++++ .../test_puppeteer_v1.2.x_connect.js | 18 + .../test_puppeteer_v1.2.x_defaultArgs.js | 14 + .../test_puppeteer_v1.2.x_executablePath.js | 14 + .../test_puppeteer_v1.2.x_launch.js | 18 + 5 files changed, 1536 insertions(+) create mode 100644 definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/puppeteer_v1.2.x.js create mode 100644 definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/test_puppeteer_v1.2.x_connect.js create mode 100644 definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/test_puppeteer_v1.2.x_defaultArgs.js create mode 100644 definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/test_puppeteer_v1.2.x_executablePath.js create mode 100644 definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/test_puppeteer_v1.2.x_launch.js diff --git a/definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/puppeteer_v1.2.x.js b/definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/puppeteer_v1.2.x.js new file mode 100644 index 0000000000..72a623953f --- /dev/null +++ b/definitions/npm/puppeteer_v1.2.x/flow_v0.58.x-/puppeteer_v1.2.x.js @@ -0,0 +1,1472 @@ +// @flow + +/** + * Based on typescript definitions found at the url below + * https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/puppeteer + */ + +import ChildProcess from 'child_process'; +import EventEmitter from 'events'; + +/** Keyboard provides an api for managing a virtual keyboard. */ +type $npm$puppeteer$Keyboard = { + /** + * Dispatches a keydown event. + * @param key Name of key to press, such as ArrowLeft. + * @param options Specifies a input text event. + */ + down(key: string, options?: { text?: string }): Promise, + + /** Shortcut for `keyboard.down` and `keyboard.up`. */ + press(key: string, options?: { delay?: number, text?: string }): Promise, + + /** Dispatches a `keypress` and `input` event. This does not send a `keydown` or keyup `event`. */ + sendCharacter(char: string): Promise, + + /** + * Sends a keydown, keypress/input, and keyup event for each character in the text. + * @param text A text to type into a focused element. + * @param options Specifies the typing options. + */ + type(text: string, options?: { delay?: number }): Promise, + + /** + * Dispatches a keyup event. + * @param key Name of key to release, such as ArrowLeft. + */ + up(key: string): Promise, +}; + +type $npm$puppeteer$MousePressOptions = { + /** + * left, right, or middle. + * @default left + */ + button?: $npm$puppeteer$MouseButtons, + + /** + * The number of clicks. + * @default 1 + */ + clickCount?: number, +}; + +type $npm$puppeteer$Mouse = { + /** + * Shortcut for `mouse.move`, `mouse.down` and `mouse.up`. + * @param x The x position. + * @param y The y position. + * @param options The click options. + */ + click(x: number, y: number, options?: $npm$puppeteer$ClickOptions): Promise, + + /** + * Dispatches a `mousedown` event. + * @param options The mouse press options. + */ + down(options?: $npm$puppeteer$MousePressOptions): Promise, + + /** + * Dispatches a `mousemove` event. + * @param x The x position. + * @param y The y position. + * @param options The mouse move options. + */ + move(x: number, y: number, options?: { steps: number }): Promise, + /** + * Dispatches a `mouseup` event. + * @param options The mouse press options. + */ + up(options?: $npm$puppeteer$MousePressOptions): Promise, +}; + +type $npm$puppeteer$Touchscreen = { + /** + * Dispatches a touchstart and touchend event. + * @param x The x position. + * @param y The y position. + */ + tap(x: number, y: number): Promise, +}; + +/** + * You can use `tracing.start` and `tracing.stop` to create a trace file which can be opened in Chrome DevTools or timeline viewer. + */ +type $npm$puppeteer$Tracing = { + start(options: $npm$puppeteer$TracingStartOptions): Promise, + + stop(): Promise, +}; + +type $npm$puppeteer$TracingStartOptions = { + categories?: Array, + path: string, + screenshots?: boolean, +}; + +/** Dialog objects are dispatched by page via the 'dialog' event. */ +type $npm$puppeteer$Dialog = { + /** + * Accepts the dialog. + * @param promptText A text to enter in prompt. Does not cause any effects if the dialog's type is not prompt. + */ + accept(promptText?: string): Promise, + + /** If dialog is prompt, returns default prompt value. Otherwise, returns empty string. */ + defaultValue(): string, + + /** Dismiss the dialog */ + dismiss(): Promise, + + /** Returns the message displayed in the dialog. */ + message(): string, + + /** The dialog type. Dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`. */ + type(): 'alert' | 'beforeunload' | 'confirm' | 'prompt', +}; + +/** ConsoleMessage objects are dispatched by page via the 'console' event. */ +type $npm$puppeteer$ConsoleMessage = { + /** The message arguments. */ + args(): Array<$npm$puppeteer$JSHandle>, + + /** The message text. */ + text(): string, + + type(): + | 'log' + | 'debug' + | 'info' + | 'error' + | 'warning' + | 'dir' + | 'dirxml' + | 'table' + | 'trace' + | 'clear' + | 'startGroup' + | 'startGroupCollapsed' + | 'endGroup' + | 'assert' + | 'profile' + | 'profileEnd' + | 'count' + | 'timeEnd', +}; + +type $npm$puppeteer$PageEvents = + | 'console' + | 'dialog' + | 'error' + | 'frameattached' + | 'framedetached' + | 'framenavigated' + | 'load' + | 'pageerror' + | 'request' + | 'requestfailed' + | 'requestfinished' + | 'response'; + +type $npm$puppeteer$BrowserEvents = + | 'disconnected' + | 'targetchanged' + | 'targetcreated' + | 'targetdestroyed'; + +type $npm$puppeteer$AuthOptions = { + password: string, + username: string, +}; + +type $npm$puppeteer$MouseButtons = 'left' | 'right' | 'middle'; + +type $npm$puppeteer$ClickOptions = { + /** defaults to left */ + button?: $npm$puppeteer$MouseButtons, + + /** defaults to 1 */ + clickCount?: number, + + /** + * Time to wait between mousedown and mouseup in milliseconds. + * Defaults to 0. + */ + delay?: number, +}; + +/** Represents a browser cookie. */ +type $npm$puppeteer$Cookie = { + /** The cookie domain. */ + domain: string, + + /** The cookie Unix expiration time in seconds. */ + expires: number, + + /** The cookie http only flag. */ + httpOnly: boolean, + + /** The cookie name. */ + name: string, + + /** The cookie path. */ + path: string, + + /** The cookie same site definition. */ + sameSite: 'Strict' | 'Lax', + + /** The cookie secure flag. */ + secure: boolean, + + /** The cookie value. */ + value: string, +}; + +type $npm$puppeteer$DeleteCookie = { + domain?: string, + /** The cookie name. */ + name: string, + path?: string, + secure?: boolean, + url?: string, +}; + +type $npm$puppeteer$SetCookie = { + /** The cookie domain. */ + domain?: string, + + /** The cookie Unix expiration time in seconds. */ + expires?: number, + + /** The cookie http only flag. */ + httpOnly?: boolean, + + /** The cookie name. */ + name: string, + + /** The cookie path. */ + path?: string, + + /** The cookie same site definition. */ + sameSite?: 'Strict' | 'Lax', + + /** The cookie secure flag. */ + secure?: boolean, + + /** The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. */ + url?: string, + + /** The cookie value. */ + value: string, +}; + +type $npm$puppeteer$Viewport = { + /** + * Specify device scale factor (can be thought of as dpr). + * @default 1 + */ + deviceScaleFactor?: number, + + /** + * Specifies if viewport supports touch events. + * @default false + */ + hasTouch?: boolean, + + /** The page height in pixels. */ + height: number, + + /** + * Specifies if viewport is in landscape mode. + * @default false + */ + isLandscape?: boolean, + + /** + * Whether the `meta viewport` tag is taken into account. + * @default false + */ + isMobile?: boolean, + + /** The page width in pixels. */ + width: number, +}; + +/** Page emulation options. */ +type $npm$puppeteer$EmulateOptions = { + /** The emulated user-agent. */ + userAgent?: string, + + /** The viewport emulation options. */ + viewport?: $npm$puppeteer$Viewport, +}; + +type $npm$puppeteer$EvaluateFn = string | ((...args: Array) => mixed); + +type $npm$puppeteer$LoadEvent = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'; + +/** The navigation options. */ +type $npm$puppeteer$NavigationOptions = { + /** + * Maximum navigation time in milliseconds, pass 0 to disable timeout. + * @default 30000 + */ + timeout?: number, + /** + * When to consider navigation succeeded. + * @default load Navigation is consider when the `load` event is fired. + */ + waitUntil?: $npm$puppeteer$LoadEvent | Array<$npm$puppeteer$LoadEvent>, +}; + +type $npm$puppeteer$PDFFormat = + | 'Letter' + | 'Legal' + | 'Tabload' + | 'Ledger' + | 'A0' + | 'A1' + | 'A2' + | 'A3' + | 'A4' + | 'A5'; + +type $npm$puppeteer$PDFOptions = { + /** + * Display header and footer. + * @default false + */ + displayHeaderFooter?: boolean, + + /** + * HTML template for the print footer. Should be valid HTML markup with following classes used to inject printing values into them: + * - `date` formatted print date + * - `title` document title + * - `url` document location + * - `pageNumber` current page number + * - `totalPages` total pages in the document + */ + footerTemplate?: string, + + /** Paper format. If set, takes priority over width or height options. Defaults to 'Letter'. */ + format?: $npm$puppeteer$PDFFormat, + + /** + * HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: + * - `date` formatted print date + * - `title` document title + * - `url` document location + * - `pageNumber` current page number + * - `totalPages` total pages in the document + */ + headerTemplate?: string, + + /** Paper height, accepts values labeled with units. */ + height?: string, + + /** + * Paper orientation. + * @default false + */ + landscape?: boolean, + + /** Paper margins, defaults to none. */ + margin?: { + /** Bottom margin, accepts values labeled with units. */ + bottom?: string, + + /** Left margin, accepts values labeled with units. */ + left?: string, + + /** Right margin, accepts values labeled with units. */ + right?: string, + + /** Top margin, accepts values labeled with units. */ + top?: string, + }, + + /** + * Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty + * string, which means print all pages. + */ + pageRanges?: string, + + /** + * The file path to save the PDF to. + * If `path` is a relative path, then it is resolved relative to current working directory. + * If no path is provided, the PDF won't be saved to the disk. + */ + path?: string, + + /** + * Print background graphics. + * @default false + */ + printBackground?: boolean, + + /** + * Scale of the webpage rendering. + * @default 1 + */ + scale?: number, + + /** Paper width, accepts values labeled with units. */ + width?: string, +}; + +/** Defines the screenshot options. */ +type $npm$puppeteer$ScreenshotOptions = { + /** + * An object which specifies clipping region of the page. + */ + clip?: $npm$puppeteer$BoundingBox, + + /** + * When true, takes a screenshot of the full scrollable page. + * @default false + */ + fullPage?: boolean, + + /** + * Hides default white background and allows capturing screenshots with transparency. + * @default false + */ + omitBackground?: boolean, + + /** + * The file path to save the image to. The screenshot type will be inferred from file extension. + * If `path` is a relative path, then it is resolved relative to current working directory. + * If no path is provided, the image won't be saved to the disk. + */ + path?: string, + + /** The quality of the image, between 0-100. Not applicable to png images. */ + quality?: number, + + /** + * The screenshot type. + * @default png + */ + type?: 'jpeg' | 'png', +}; + +/** Options for `addStyleTag` */ +type $npm$puppeteer$StyleTagOptions = { + /** Raw CSS content to be injected into frame. */ + content?: string, + + /** Path to the CSS file to be injected into frame. If `path` is a relative path, then it is resolved relative to current working directory. */ + path?: string, + + /** Url of the tag. */ + url?: string, +}; +/** Options for `addScriptTag` */ +type $npm$puppeteer$ScriptTagOptions = { + /** Raw JavaScript content to be injected into frame. */ + content?: string, + + /** Path to the JavaScript file to be injected into frame. If `path` is a relative path, then it is resolved relative to current working directory. */ + path?: string, + + /** Script type. Use 'module' in order to load a Javascript ES6 module. */ + type?: string, + + /** Url of a script to be added. */ + url?: string, +}; + +type $npm$puppeteer$PageFnOptions = { + polling?: 'raf' | 'mutation' | number, + timeout?: number, +}; + +type $npm$puppeteer$BoundingBox = { + /** The height. */ + height: number, + + /** The width. */ + width: number, + + /** The x-coordinate of top-left corner. */ + x: number, + + /** The y-coordinate of top-left corner. */ + y: number, +}; + +/** + * Represents an in-page DOM element. ElementHandles can be created with the page.$ method. + */ +type $npm$puppeteer$ElementHandle = $npm$puppeteer$JSHandle & { + /** + * The method runs element.querySelector within the page. If no element matches the selector, the return value resolve to null. + * @param selector A selector to query element for + * @since 0.13.0 + */ + $(selector: string): Promise<$npm$puppeteer$ElementHandle | null>, + + /** + * The method runs element.querySelectorAll within the page. If no elements match the selector, the return value resolve to []. + * @param selector A selector to query element for + * @since 0.13.0 + */ + $$(selector: string): Promise>, + + /** + * @param selector XPath expression to evaluate. + */ + $x(expression: string): Promise>, + + /** + * This method returns the value resolve to the bounding box of the element (relative to the main frame), or null if the element is not visible. + */ + boundingBox(): Promise<$npm$puppeteer$BoundingBox | null>, + + /** + * This method scrolls element into view if needed, and then uses page.mouse to click in the center of the element. + * If the element is detached from DOM, the method throws an error. + * @param options Specifies the options. + * @since 0.9.0 + */ + click(options?: $npm$puppeteer$ClickOptions): Promise, + + /** + * @returns Resolves to the content frame for element handles referencing iframe nodes, or null otherwise. + * @since 1.2.0 + */ + contentFrame(): Promise, + + /** + * Calls focus on the element. + */ + focus(): Promise, + + /** + * This method scrolls element into view if needed, and then uses page.mouse to hover over the center of the element. + * If the element is detached from DOM, the method throws an error. + */ + hover(): Promise, + + /** + * Focuses the element, and then uses keyboard.down and keyboard.up. + * @param key Name of key to press, such as ArrowLeft. See USKeyboardLayout for a list of all key names. + * @param options The text and delay options. + */ + press(key: string, options?: { delay?: number, text?: string }): Promise, + + /** + * This method scrolls element into view if needed, and then uses page.screenshot to take a screenshot of the element. + * If the element is detached from DOM, the method throws an error. + * @param options Same options as in page.screenshot. + */ + screenshot(options?: $npm$puppeteer$ScreenshotOptions): Promise, + + /** + * This method scrolls element into view if needed, and then uses touchscreen.tap to tap in the center of the element. + * If the element is detached from DOM, the method throws an error. + */ + tap(): Promise, + + toString(): string, + + /** + * Focuses the element, and then sends a keydown, keypress/input, and keyup event for each character in the text. + * @param text A text to type into a focused element. + * @param options The typing options. + */ + type(text: string, options?: { delay: number }): Promise, + + /** + * This method expects elementHandle to point to an input element. + * @param filePaths Sets the value of the file input these paths. If some of the filePaths are relative paths, then they are resolved relative to current working directory. + */ + uploadFile(...filePaths: Array): Promise, +}; + +/** The class represents a context for JavaScript execution. */ +type $npm$puppeteer$ExecutionContext = { + evaluate(fn: $npm$puppeteer$EvaluateFn, ...args: Array): Promise, + evaluateHandle( + fn: $npm$puppeteer$EvaluateFn, + ...args: Array + ): Promise<$npm$puppeteer$JSHandle>, + queryObjects(prototypeHandle: $npm$puppeteer$JSHandle): $npm$puppeteer$JSHandle, +}; + +/** JSHandle represents an in-page JavaScript object. */ +type $npm$puppeteer$JSHandle = { + /** + * Returns a ElementHandle + */ + asElement(): $npm$puppeteer$ElementHandle | null, + + /** + * Stops referencing the element handle. + */ + dispose(): Promise, + + /** + * Gets the execution context. + */ + executionContext(): $npm$puppeteer$ExecutionContext, + + /** + * Returns a map with property names as keys and JSHandle instances for the property values. + */ + getProperties(): Promise>, + + /** + * Fetches a single property from the objectHandle. + * @param propertyName The property to get. + */ + getProperty(propertyName: string): Promise<$npm$puppeteer$JSHandle>, + + /** + * Returns a JSON representation of the object. + * The JSON is generated by running JSON.stringify on the object in page and consequent JSON.parse in puppeteer. + * @throws The method will throw if the referenced object is not stringifiable. + */ + jsonValue(): Promise, +}; + +type $npm$puppeteer$Metrics = { + /** Number of documents in the page. */ + Documents: number, + + /** Number of frames in the page. */ + Frames: number, + + /** Number of events in the page. */ + JSEventListeners: number, + + /** Total JavaScript heap size. */ + JSHeapTotalSize: number, + + /** Used JavaScript heap size. */ + JSHeapUsedSize: number, + /** Total number of full or partial page layout. */ + LayoutCount: number, + + /** Combined durations of all page layouts. */ + LayoutDuration: number, + + /** Number of DOM nodes in the page. */ + Nodes: number, + + /** Total number of page style recalculations. */ + RecalcStyleCount: number, + + /** Combined duration of all page style recalculations. */ + RecalcStyleDuration: number, + + /** Combined duration of JavaScript execution. */ + ScriptDuration: number, + + /** Combined duration of all tasks performed by the browser. */ + TaskDuration: number, + + /** The timestamp when the metrics sample was taken. */ + Timestamp: number, +}; + +type $npm$puppeteer$Headers = { [key: string]: string }; +type $npm$puppeteer$HttpMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'OPTIONS'; + +type $npm$puppeteer$ResourceType = + | 'document' + | 'stylesheet' + | 'image' + | 'media' + | 'font' + | 'script' + | 'texttrack' + | 'xhr' + | 'fetch' + | 'eventsource' + | 'websocket' + | 'manifest' + | 'other'; + +type $npm$puppeteer$Overrides = { + headers?: $npm$puppeteer$Headers, + method?: $npm$puppeteer$HttpMethod, + postData?: string, + url?: string, +}; + +/** Represents a page request. */ +type $npm$puppeteer$Request = { + /** + * Aborts request. + * To use this, request interception should be enabled with `page.setRequestInterception`. + * @throws An exception is immediately thrown if the request interception is not enabled. + */ + abort(): Promise, + + /** + * Continues request with optional request overrides. + * To use this, request interception should be enabled with `page.setRequestInterception`. + * @throws An exception is immediately thrown if the request interception is not enabled. + */ + continue(overrides?: $npm$puppeteer$Overrides): Promise, + + /** + * @returns The `Frame` object that initiated the request, or `null` if navigating to error pages + */ + frame(): Promise, + + /** + * An object with HTTP headers associated with the request. + * All header names are lower-case. + */ + headers(): $npm$puppeteer$Headers, + /** Returns the request's method (GET, POST, etc.) */ + + method(): $npm$puppeteer$HttpMethod, + + /** Contains the request's post body, if any. */ + postData(): ?string, + + /** + * A `redirectChain` is a chain of requests initiated to fetch a resource. + * + * - If there are no redirects and the request was successful, the chain will be empty. + * - If a server responds with at least a single redirect, then the chain will contain all the requests that were redirected. + * + * `redirectChain` is shared between all the requests of the same chain. + * + * @since 1.2.0 + */ + redirectChain(): Array, + + /** Contains the request's resource type as it was perceived by the rendering engine. */ + resourceType(): $npm$puppeteer$ResourceType, + + /** + * Fulfills request with given response. + * To use this, request interception should be enabled with `page.setRequestInterception`. + * @throws An exception is immediately thrown if the request interception is not enabled. + * @param response The response options that will fulfill this request. + */ + respond(response: $npm$puppeteer$RespondOptions): Promise, + + /** A matching `Response` object, or `null` if the response has not been received yet. */ + response(): ?$npm$puppeteer$Response, + + /** Contains the URL of the request. */ + url(): string, +}; + +/** Options for `Request.respond` method */ +type $npm$puppeteer$RespondOptions = { + /** Specifies the response body. */ + body?: Buffer | string, + + /** Specifies the Content-Type response header. */ + contentType?: string, + + /** Specifies the response headers. */ + headers?: $npm$puppeteer$Headers, + + /** + * Specifies the response status code. + * @default 200 + */ + status?: number, +}; + +/** Response class represents responses which are received by page. */ +type $npm$puppeteer$Response = { + /** Promise which resolves to a buffer with response body. */ + buffer(): Promise, + + /** True if the response was served from either the browser's disk cache or memory cache. */ + fromCache(): boolean, + + /** True if the response was served by a service worker. */ + fromServiceWorker(): boolean, + + /** An object with HTTP headers associated with the response. All header names are lower-case. */ + headers(): $npm$puppeteer$Headers, + + /** + * Promise which resolves to a JSON representation of response body. + * @throws This method will throw if the response body is not parsable via `JSON.parse`. + */ + json(): Promise, + + /** Contains a boolean stating whether the response was successful (status in the range 200-299) or not. */ + ok(): boolean, + + /** A matching Request object. */ + request(): $npm$puppeteer$Request, + + /** Contains the status code of the response (e.g., 200 for a success). */ + status(): number, + + /** Promise which resolves to a text representation of response body. */ + text(): Promise, + + /** Contains the URL of the response. */ + url(): string, +}; + +type $npm$puppeteer$FrameBase = { + /** + * The method runs document.querySelector within the page. + * If no element matches the selector, the return value resolve to null. + */ + $(selector: string): Promise, + + /** + * The method runs document.querySelectorAll within the page. If no elements match the selector, the return value resolve to []. + */ + $$(selector: string): Promise>, + + /** + * This method runs document.querySelectorAll within the page and passes it as the first argument to `fn`. + * If `fn` returns a Promise, then $$eval would wait for the promise to resolve and return its value. + * @param selector A selector to query frame for + * @param fn Function to be evaluated in browser context + * @param args Arguments to pass to pageFunction + * @returns Promise which resolves to the return value of pageFunction + */ + $$eval( + selector: string, + pageFunction: (elements: NodeList, ...args: Array) => mixed, + ...args: Array + ): Promise, + + /** + * This method runs document.querySelector within the page and passes it as the first argument to `fn`. + * If there's no element matching selector, the method throws an error. + * If `fn` returns a Promise, then $eval would wait for the promise to resolve and return its value. + */ + $eval( + selector: string, + pageFunction: (element: Element, ...args: Array) => mixed, + ...args: Array + ): Promise, + + /** + * @param expression XPath expression to evaluate. + */ + $x(expression: string): Promise>, + + /** Adds a `