[change] Update flow-bin to 0.95.1

Fix related type errors

Close #1269

Co-authored-by: Nicolas Gallagher <nicolasgallagher@gmail.com>
This commit is contained in:
Mathieu Acthernoene
2019-03-18 13:00:05 -07:00
committed by Nicolas Gallagher
co-authored by Nicolas Gallagher
parent b732cec83e
commit 36dacb2052
15 changed files with 41 additions and 27 deletions
+1 -2
View File
@@ -1,5 +1,5 @@
[version]
^0.63.0
^0.95.1
[ignore]
<PROJECT_ROOT>/.*/__tests__/.*
@@ -14,4 +14,3 @@
<PROJECT_ROOT>/types
[options]
+1 -1
View File
@@ -47,7 +47,7 @@
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.7.0",
"flow-bin": "^0.63.1",
"flow-bin": "^0.95.1",
"glob": "^7.1.2",
"husky": "^0.14.3",
"inline-style-prefixer": "^5.0.3",
+3 -4
View File
@@ -15,8 +15,7 @@ import PickerItem from './PickerItem';
import PickerItemPropType from './PickerItemPropType';
import PickerStylePropTypes from './PickerStylePropTypes';
import StyleSheetPropType from '../../modules/StyleSheetPropType';
import StyleSheet from '../StyleSheet';
import TextPropTypes from '../Text/TextPropTypes';
import StyleSheet, { type StyleObj } from '../StyleSheet';
import { arrayOf, bool, func, number, oneOfType, string } from 'prop-types';
import ViewPropTypes, { type ViewProps } from '../ViewPropTypes';
@@ -27,10 +26,10 @@ type Props = ViewProps & {
enabled?: boolean,
onValueChange?: Function,
selectedValue?: number | string,
style?: pickerStyleType,
style?: StyleObj,
testID?: string,
/* compat */
itemStyle?: TextPropTypes.style,
itemStyle?: StyleObj,
mode?: string,
prompt?: string
};
@@ -0,0 +1,11 @@
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
type Atom = number | boolean | Object | Array<?Atom>;
export type StyleObj = Atom;
@@ -110,7 +110,9 @@ export function inline(style: Style) {
export function stringifyValueWithProperty(value: Value, property: ?string) {
// e.g., 0 => '0px', 'black' => 'rgba(0,0,0,1)'
const normalizedValue = normalizeValueWithProperty(value, property);
return typeof normalizedValue !== 'string' ? JSON.stringify(normalizedValue) : normalizedValue;
return typeof normalizedValue !== 'string'
? JSON.stringify(normalizedValue || '')
: normalizedValue;
}
/**
@@ -29,7 +29,11 @@ function textShadowReducer(resolvedStyle, style) {
const blurRadius = normalizeValueWithProperty(radius);
const color = normalizeValueWithProperty(textShadowColor, 'textShadowColor');
if (color && (height !== 0 || width !== 0 || radius !== 0)) {
if (
color &&
(height !== 0 || width !== 0 || radius !== 0) &&
(offsetX != null && offsetY != null && blurRadius != null)
) {
resolvedStyle.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`;
}
}
@@ -10,9 +10,7 @@
import ReactNativePropRegistry from '../../modules/ReactNativePropRegistry';
import invariant from 'fbjs/lib/invariant';
type Atom = number | boolean | Object | Array<?Atom>;
type StyleObj = Atom;
import type { StyleObj } from './StyleSheetTypes';
function getStyle(style) {
if (typeof style === 'number') {
@@ -31,7 +29,6 @@ function flattenStyle(style: ?StyleObj): ?Object {
}
if (!Array.isArray(style)) {
// $FlowFixMe
return getStyle(style);
}
@@ -24,10 +24,11 @@ const colorProps = {
};
export default function normalizeValueWithProperty(value: any, property?: ?string) {
let returnValue = value;
if ((property == null || !unitlessNumbers[property]) && typeof value === 'number') {
value = `${value}px`;
returnValue = `${value}px`;
} else if (property != null && colorProps[property]) {
value = normalizeColor(value);
returnValue = normalizeColor(value);
}
return value;
return returnValue;
}
@@ -19,7 +19,7 @@ const resolveShadowValue = (style: Object) => {
const offsetY = normalizeValueWithProperty(height);
const blurRadius = normalizeValueWithProperty(shadowRadius || 0);
const color = normalizeColor(shadowColor || 'black', shadowOpacity);
if (color) {
if (color != null && offsetX != null && offsetY != null && blurRadius != null) {
return `${offsetX} ${offsetY} ${blurRadius} ${color}`;
}
};
@@ -67,15 +67,13 @@ export default function validate(key: string, styles: Object) {
for (const k in obj) {
const prop = k.trim();
const value = obj[prop];
const isValidProp = validProperties[prop];
const isInvalidShorthand = invalidShortforms[prop];
let isInvalid = false;
if (value === null) {
continue;
}
if (!isValidProp) {
if (validProperties[prop] == null) {
let suggestion = '';
if (prop === 'animation' || prop === 'animationName') {
suggestion = 'Did you mean "animationKeyframes"?';
@@ -85,7 +83,7 @@ export default function validate(key: string, styles: Object) {
suggestion = 'Did you mean "writingDirection"?';
} else if (prop === 'verticalAlign') {
suggestion = 'Did you mean "textAlignVertical"?';
} else if (isInvalidShorthand) {
} else if (invalidShortforms[prop]) {
suggestion = 'Please use long-form properties.';
}
isInvalid = true;
@@ -12,6 +12,7 @@ import EdgeInsetsPropType, { type EdgeInsetsProp } from '../EdgeInsetsPropType';
import StyleSheetPropType from '../../modules/StyleSheetPropType';
import ViewStylePropTypes from './ViewStylePropTypes';
import { any, array, arrayOf, bool, func, object, oneOf, oneOfType, string } from 'prop-types';
import { type StyleObj } from '../StyleSheet/StyleSheetTypes';
const stylePropType = StyleSheetPropType(ViewStylePropTypes);
@@ -65,7 +66,7 @@ export type ViewProps = {
onTouchStart?: Function,
onTouchStartCapture?: Function,
pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto',
style?: stylePropType,
style?: StyleObj,
testID?: string,
// web extensions
onContextMenu?: Function,
@@ -346,7 +346,7 @@ class AnimatedInterpolation extends AnimatedWithChildren {
super.__detach();
}
__transformDataType(range: Array<any>) {
__transformDataType(range: Array<string>): Array<number> {
// Change the string array type to number array
// So we can reuse the same logic in iOS and Android platform
return range.map(function(value) {
@@ -16,6 +16,8 @@ import invariant from 'fbjs/lib/invariant';
// Note(vjeux): this would be better as an interface but flow doesn't
// support them yet
class AnimatedNode {
+update: () => void
__attach(): void {}
__detach(): void {
if (this.__isNative && this.__nativeTag != null) {
@@ -57,7 +57,6 @@ function _flush(rootNode: AnimatedValue): void {
}
}
findAnimatedStyles(rootNode);
/* $FlowFixMe */
animatedStyles.forEach(animatedStyle => animatedStyle.update());
}
+4 -3
View File
@@ -4797,9 +4797,10 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
flow-bin@^0.63.1:
version "0.63.1"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.63.1.tgz#ab00067c197169a5fb5b4996c8f6927b06694828"
flow-bin@^0.95.1:
version "0.95.1"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.95.1.tgz#633113831ccff4b7ee70a2730f63fc43b69ba85f"
integrity sha512-06IOC/pqPMNRYtC6AMZEWYR9Fi6UdBC7gImGinPuNUpPZFnP5E9/0cBCl3DWrH4zz/gSM2HdDilU7vPGpYIr2w==
flush-write-stream@^1.0.0:
version "1.0.3"