Fix some flow errors that appear
Summary: <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html Happy contributing! --> There are some errors I noticed after upgrading my flow version. I had them in my project, and they were also reported in #11655. These errors were ignored on master, but I went through and fixed them so the static analysis will work still. After these changes, I receive no errors using flow `0.60.1` on latest master, or using `0.59` in my local project (which does not have the requisite ignores included). - init a new project `react-native init --version <path-to-repo> helloworld` - add the flow binary `yarn add -D flow-bin` - run flow `yarn flow` - make sure there are no errors in the project. ``` No errors! ✨ Done in 23.60s. ``` <!-- Help reviewers and the release process by writing your own release notes **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [-{Component}-] [ INTERNAL ] [ ENHANCEMENT ] [ {File} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| [CATEGORY] [TYPE] [LOCATION] - MESSAGE EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> [GENERAL][BUGFIX][./Libraries] - Fix up some flow definitions Closes https://github.com/facebook/react-native/pull/17086 Differential Revision: D6509112 Pulled By: hramos fbshipit-source-id: a61145b5306c666ab6510ccb9eea02d96f3decb3
This commit is contained in:
parent
1988ba1d79
commit
76a2ca4c9c
|
@ -62,22 +62,14 @@ class Easing {
|
||||||
/**
|
/**
|
||||||
* A stepping function, returns 1 for any positive value of `n`.
|
* A stepping function, returns 1 for any positive value of `n`.
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static step0(n: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static step0(n) {
|
|
||||||
return n > 0 ? 1 : 0;
|
return n > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A stepping function, returns 1 if `n` is greater than or equal to 1.
|
* A stepping function, returns 1 if `n` is greater than or equal to 1.
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static step1(n: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static step1(n) {
|
|
||||||
return n >= 1 ? 1 : 0;
|
return n >= 1 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +79,7 @@ class Easing {
|
||||||
*
|
*
|
||||||
* http://cubic-bezier.com/#0,0,1,1
|
* http://cubic-bezier.com/#0,0,1,1
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static linear(t: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static linear(t) {
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,11 +102,7 @@ class Easing {
|
||||||
*
|
*
|
||||||
* http://easings.net/#easeInQuad
|
* http://easings.net/#easeInQuad
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static quad(t: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static quad(t) {
|
|
||||||
return t * t;
|
return t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,11 +112,7 @@ class Easing {
|
||||||
*
|
*
|
||||||
* http://easings.net/#easeInCubic
|
* http://easings.net/#easeInCubic
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static cubic(t: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static cubic(t) {
|
|
||||||
return t * t * t;
|
return t * t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,17 +122,8 @@ class Easing {
|
||||||
* n = 4: http://easings.net/#easeInQuart
|
* n = 4: http://easings.net/#easeInQuart
|
||||||
* n = 5: http://easings.net/#easeInQuint
|
* n = 5: http://easings.net/#easeInQuint
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static poly(n: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
return (t: number) => Math.pow(t, n);
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static poly(n) {
|
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an
|
|
||||||
* error caught by Flow 0.59 which was not caught before. Most likely, this
|
|
||||||
* error is because an exported function parameter is missing an
|
|
||||||
* annotation. Without an annotation, these parameters are uncovered by
|
|
||||||
* Flow. */
|
|
||||||
return (t) => Math.pow(t, n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,11 +131,7 @@ class Easing {
|
||||||
*
|
*
|
||||||
* http://easings.net/#easeInSine
|
* http://easings.net/#easeInSine
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static sin(t: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static sin(t) {
|
|
||||||
return 1 - Math.cos(t * Math.PI / 2);
|
return 1 - Math.cos(t * Math.PI / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,11 +140,7 @@ class Easing {
|
||||||
*
|
*
|
||||||
* http://easings.net/#easeInCirc
|
* http://easings.net/#easeInCirc
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static circle(t: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static circle(t) {
|
|
||||||
return 1 - Math.sqrt(1 - t * t);
|
return 1 - Math.sqrt(1 - t * t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,11 +149,7 @@ class Easing {
|
||||||
*
|
*
|
||||||
* http://easings.net/#easeInExpo
|
* http://easings.net/#easeInExpo
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static exp(t: number) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static exp(t) {
|
|
||||||
return Math.pow(2, 10 * (t - 1));
|
return Math.pow(2, 10 * (t - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,15 @@ const ASSET_TYPE_OPTIONS = {
|
||||||
Photos: 'Photos',
|
Photos: 'Photos',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type GetPhotosParams = {
|
||||||
|
first: number,
|
||||||
|
after?: string,
|
||||||
|
groupTypes?: $Keys<typeof GROUP_TYPES_OPTIONS>,
|
||||||
|
groupName?: string,
|
||||||
|
assetType?: $Keys<typeof ASSET_TYPE_OPTIONS>,
|
||||||
|
mimeTypes?: Array<string>,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape of the param arg for the `getPhotos` function.
|
* Shape of the param arg for the `getPhotos` function.
|
||||||
*/
|
*/
|
||||||
|
@ -73,6 +82,35 @@ const getPhotosParamChecker = createStrictShapeTypeChecker({
|
||||||
mimeTypes: PropTypes.arrayOf(PropTypes.string),
|
mimeTypes: PropTypes.arrayOf(PropTypes.string),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
type GetPhotosReturn = Promise<{
|
||||||
|
edges: Array<{
|
||||||
|
node: {
|
||||||
|
type: string,
|
||||||
|
group_name: string,
|
||||||
|
image: {
|
||||||
|
uri: string,
|
||||||
|
height: number,
|
||||||
|
width: number,
|
||||||
|
isStored?: boolean,
|
||||||
|
playableDuration: number,
|
||||||
|
},
|
||||||
|
timestamp: number,
|
||||||
|
location?: {
|
||||||
|
latitude?: number,
|
||||||
|
longitude?: number,
|
||||||
|
altitude?: number,
|
||||||
|
heading?: number,
|
||||||
|
speed?: number,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}>,
|
||||||
|
page_info: {
|
||||||
|
has_next_page: boolean,
|
||||||
|
start_cursor?: string,
|
||||||
|
end_cursor?: string,
|
||||||
|
},
|
||||||
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape of the return value of the `getPhotos` function.
|
* Shape of the return value of the `getPhotos` function.
|
||||||
*/
|
*/
|
||||||
|
@ -162,8 +200,8 @@ class CameraRoll {
|
||||||
|
|
||||||
invariant(
|
invariant(
|
||||||
type === 'photo' || type === 'video' || type === undefined,
|
type === 'photo' || type === 'video' || type === undefined,
|
||||||
// $FlowFixMe(>=0.28.0)
|
`The second argument to saveToCameraRoll must be 'photo' or 'video'. You passed ${type ||
|
||||||
`The second argument to saveToCameraRoll must be 'photo' or 'video'. You passed ${type}`,
|
'unknown'}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mediaType = 'photo';
|
let mediaType = 'photo';
|
||||||
|
@ -259,11 +297,7 @@ class CameraRoll {
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static getPhotos(params: GetPhotosParams): GetPhotosReturn {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static getPhotos(params) {
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
checkPropTypes(
|
checkPropTypes(
|
||||||
{params: getPhotosParamChecker},
|
{params: getPhotosParamChecker},
|
||||||
|
|
|
@ -24,11 +24,7 @@ var invariant = require('fbjs/lib/invariant');
|
||||||
const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
||||||
|
|
||||||
class StyleSheetValidation {
|
class StyleSheetValidation {
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static validateStyleProp(prop: string, style: Object, caller: string) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static validateStyleProp(prop, style, caller) {
|
|
||||||
if (!__DEV__) {
|
if (!__DEV__) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +32,6 @@ class StyleSheetValidation {
|
||||||
var message1 = '"' + prop + '" is not a valid style property.';
|
var message1 = '"' + prop + '" is not a valid style property.';
|
||||||
var message2 = '\nValid style props: ' +
|
var message2 = '\nValid style props: ' +
|
||||||
JSON.stringify(Object.keys(allStylePropTypes).sort(), null, ' ');
|
JSON.stringify(Object.keys(allStylePropTypes).sort(), null, ' ');
|
||||||
/* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an
|
|
||||||
* error found when Flow v0.56 was deployed. To see the error delete this
|
|
||||||
* comment and run Flow. */
|
|
||||||
styleError(message1, style, caller, message2);
|
styleError(message1, style, caller, message2);
|
||||||
}
|
}
|
||||||
var error = allStylePropTypes[prop](
|
var error = allStylePropTypes[prop](
|
||||||
|
@ -50,21 +43,11 @@ class StyleSheetValidation {
|
||||||
ReactPropTypesSecret,
|
ReactPropTypesSecret,
|
||||||
);
|
);
|
||||||
if (error) {
|
if (error) {
|
||||||
/* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an
|
|
||||||
* error found when Flow v0.56 was deployed. To see the error delete this
|
|
||||||
* comment and run Flow. */
|
|
||||||
/* $FlowFixMe(>=0.56.0 site=react_native_fb,react_native_oss) This
|
|
||||||
* comment suppresses an error found when Flow v0.56 was deployed. To see
|
|
||||||
* the error delete this comment and run Flow. */
|
|
||||||
styleError(error.message, style, caller);
|
styleError(error.message, style, caller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* $FlowFixMe(>=0.59.0 site=react_native_fb) This comment suppresses an error
|
static validateStyle(name: string, styles: Object) {
|
||||||
* caught by Flow 0.59 which was not caught before. Most likely, this error
|
|
||||||
* is because an exported function parameter is missing an annotation.
|
|
||||||
* Without an annotation, these parameters are uncovered by Flow. */
|
|
||||||
static validateStyle(name, styles) {
|
|
||||||
if (!__DEV__) {
|
if (!__DEV__) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue