Chore/fix lintter and ts on source prop (#3361)

* fix: Fix types for `ReactVideoSource` to also allow `require(..)` sources

We need to be careful here to not use `any`, so I used `NodeRequire` - which is afaik present in all React Native environments as a type.

---------

Co-authored-by: Marc Rousavy <me@mrousavy.com>
Co-authored-by: olivier <olivier.bouillet@ifeelsmart.com>
This commit is contained in:
Olivier Bouillet
2023-11-18 15:39:22 +01:00
committed by GitHub
parent f2e80e9f2d
commit 80e7139897
3 changed files with 12 additions and 6 deletions

View File

@@ -1,17 +1,19 @@
import type {Component, RefObject, ComponentClass} from 'react';
import {Image, findNodeHandle} from 'react-native';
import type {ImageSourcePropType} from 'react-native';
import type {ReactVideoSource} from './types/video';
import type {ReactVideoSource, ReactVideoSourceProperties} from './types/video';
type Source = ImageSourcePropType | ReactVideoSource;
export function resolveAssetSourceForVideo(source: Source): ReactVideoSource {
export function resolveAssetSourceForVideo(
source: Source,
): ReactVideoSourceProperties {
if (typeof source === 'number') {
return {
uri: Image.resolveAssetSource(source).uri,
};
}
return source as ReactVideoSource;
return source as ReactVideoSourceProperties;
}
export function getReactTag(