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
14644924d9
commit
c04c1e2674
|
@ -35,6 +35,15 @@ const ASSET_TYPE_OPTIONS = {
|
|||
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.
|
||||
*/
|
||||
|
@ -73,6 +82,35 @@ const getPhotosParamChecker = createStrictShapeTypeChecker({
|
|||
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.
|
||||
*/
|
||||
|
@ -162,8 +200,8 @@ class CameraRoll {
|
|||
|
||||
invariant(
|
||||
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';
|
||||
|
@ -259,11 +297,7 @@ class CameraRoll {
|
|||
* }
|
||||
* ```
|
||||
*/
|
||||
/* $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. */
|
||||
static getPhotos(params) {
|
||||
static getPhotos(params: GetPhotosParams): GetPhotosReturn {
|
||||
if (__DEV__) {
|
||||
checkPropTypes(
|
||||
{params: getPhotosParamChecker},
|
||||
|
|
Loading…
Reference in New Issue