Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow type definitions are not being found #784

Closed
JameelMukadam opened this issue Apr 16, 2021 · 2 comments
Closed

Flow type definitions are not being found #784

JameelMukadam opened this issue Apr 16, 2021 · 2 comments
Labels

Comments

@JameelMukadam
Copy link

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch react-native-fast-image@8.3.4 for the project I'm working on.

Seems like the Flow type definitions are not being found because the file which is being imported is called index.cjs.js and the definition file is called index.js.flow. If I copy the index.js.flow and rename it to index.cjs.js.flow then it works.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-fast-image/dist/index.cjs.js.flow b/node_modules/react-native-fast-image/dist/index.cjs.js.flow
new file mode 100644
index 0000000..71fac3a
--- /dev/null
+++ b/node_modules/react-native-fast-image/dist/index.cjs.js.flow
@@ -0,0 +1,71 @@
+// @flow
+
+import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes'
+import type { SyntheticEvent } from 'react-native/Libraries/Types/CoreEventTypes'
+
+export type OnLoadEvent = SyntheticEvent<
+    $ReadOnly<{
+        width: number,
+        height: number,
+    }>,
+>
+
+export type OnProgressEvent = SyntheticEvent<
+    $ReadOnly<{|
+        loaded: number,
+        total: number,
+    |}>,
+>
+
+export type ResizeMode = $ReadOnly<{|
+    contain: 'contain',
+    cover: 'cover',
+    stretch: 'stretch',
+    center: 'center',
+|}>
+
+export type Priority = $ReadOnly<{|
+    low: 'low',
+    normal: 'normal',
+    high: 'high',
+|}>
+
+export type CacheControl = $ReadOnly<{|
+    immutable: 'immutable',
+    web: 'web',
+    cacheOnly: 'cacheOnly',
+|}>
+
+export type ResizeModes = $Values<ResizeMode>
+export type Priorities = $Values<Priority>
+export type CacheControls = $Values<CacheControl>
+
+export type PreloadFn = (sources: Array<FastImageSource>) => void
+export type FastImageSource = {
+    uri?: string,
+    headers?: Object,
+    priority?: Priorities,
+    cache?: CacheControls,
+}
+
+export type FastImageProps = $ReadOnly<{|
+    ...ViewProps,
+    onError?: ?() => void,
+    onLoad?: ?(event: OnLoadEvent) => void,
+    onLoadEnd?: ?() => void,
+    onLoadStart?: ?() => void,
+    onProgress?: ?(event: OnProgressEvent) => void,
+
+    source: FastImageSource | number,
+
+    resizeMode?: ?ResizeModes,
+    fallback?: ?boolean,
+    testID?: ?string,
+|}>
+
+declare export default class FastImage extends React$Component<FastImageProps> {
+    static resizeMode: ResizeMode;
+    static priority: Priority;
+    static cacheControl: CacheControl;
+    static preload: PreloadFn;
+}

This issue body was partially generated by patch-package.

@DylanVann
Copy link
Owner

I did a kind of hacky solution. I will look into just shipping ESM in a future release, which would resolve this.

github-actions bot pushed a commit that referenced this issue Sep 16, 2021
## [8.5.6](v8.5.5...v8.5.6) (2021-09-16)

### Bug Fixes

* make corresponding flow file for .cjs file ([77326e8](77326e8)), closes [#784](#784)
@github-actions
Copy link

馃帀 This issue has been resolved in version 8.5.6 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

alicayan008 pushed a commit to alicayan008/ReactNative-fast-image that referenced this issue Jul 4, 2023
## [8.5.6](DylanVann/react-native-fast-image@v8.5.5...v8.5.6) (2021-09-16)

### Bug Fixes

* make corresponding flow file for .cjs file ([77326e8](DylanVann/react-native-fast-image@77326e8)), closes [#784](DylanVann/react-native-fast-image#784)
tungxuan1656 pushed a commit to tungxuan1656/react-native-fast-image that referenced this issue Dec 26, 2023
tungxuan1656 pushed a commit to tungxuan1656/react-native-fast-image that referenced this issue Dec 26, 2023
## [8.5.6](DylanVann/react-native-fast-image@v8.5.5...v8.5.6) (2021-09-16)

### Bug Fixes

* make corresponding flow file for .cjs file ([77326e8](DylanVann@77326e8)), closes [DylanVann#784](DylanVann#784)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants