From 80417b157e04437fd211c67bdaa2764f95145431 Mon Sep 17 00:00:00 2001 From: Timur Manyanov <2737310+darkwebdev@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:00:00 +0100 Subject: [PATCH] [#285] strictNullChecks: true, fix 12 errors --- src/ebay-video/__tests__/index.stories.tsx | 6 ++--- src/ebay-video/video.tsx | 26 +++++++++++++--------- tsconfig.json | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/ebay-video/__tests__/index.stories.tsx b/src/ebay-video/__tests__/index.stories.tsx index 900288a8..1faec5e2 100644 --- a/src/ebay-video/__tests__/index.stories.tsx +++ b/src/ebay-video/__tests__/index.stories.tsx @@ -18,9 +18,9 @@ const defaultProps: EbayVideoProps = { errorText: "An error has occurred", width: 600, height: 400, - onPlay: (e: SyntheticEvent, props: PlayEventProps) => action('onPlay')(e, props), - onVolumeChange: (e: SyntheticEvent, props: VolumeChangeProps) => action('onVolumeChange')(e, props), - onLoadError: (err: Error) => action('onLoadError')(err), + onPlay: (e, props) => action('onPlay')(e, props), + onVolumeChange: (e, props) => action('onVolumeChange')(e, props), + onLoadError: (err) => action('onLoadError')(err), onReport: (e) => action('onReport')(e), } diff --git a/src/ebay-video/video.tsx b/src/ebay-video/video.tsx index 0bc203b1..5123a749 100644 --- a/src/ebay-video/video.tsx +++ b/src/ebay-video/video.tsx @@ -77,8 +77,8 @@ const EbayVideo: FC = ({ const containerRef = useRef(null) const videoRef = useRef(null) - const playerRef = useRef(null) - const uiRef = useRef(null) + const playerRef = useRef(null) + const uiRef = useRef(null) const sources = filterByType(children, EbayVideoSource).map(elementProps) @@ -143,7 +143,7 @@ const EbayVideo: FC = ({ video, reportText ) - uiRef.current.configure({ + uiRef.current?.configure({ addBigPlayButton: true, controlPanelElements: [], addSeekBar: false @@ -166,10 +166,10 @@ const EbayVideo: FC = ({ useEffect(() => { switch (action) { case 'play': - videoRef.current.play() + videoRef.current?.play() break case 'pause': - videoRef.current.pause() + videoRef.current?.pause() break default: } @@ -186,7 +186,9 @@ const EbayVideo: FC = ({ ...defaultVideoConfig, ...updatedControls }) - videoRef.current.controls = false + if (videoRef.current) { + videoRef.current.controls = false + } } const handlePlaying = (e: SyntheticEvent) => { @@ -195,15 +197,17 @@ const EbayVideo: FC = ({ showControls() if (playView === 'fullscreen') { - videoRef.current.requestFullscreen() + videoRef.current?.requestFullscreen() } setPlaying(true) - onPlay(e, { player: playerRef.current }) + if (playerRef.current) { + onPlay(e, { player: playerRef.current }) + } } const handleOnPlayClick = () => { - videoRef.current.play() + videoRef.current?.play() } const handleVolumeChange = (e: SyntheticEvent) => { @@ -217,7 +221,9 @@ const EbayVideo: FC = ({ const handleOnPause = () => { // On IOS, the controls force showing up if the video exist fullscreen while playing. // This forces the controls to always hide - videoRef.current.controls = false + if (videoRef.current) { + videoRef.current.controls = false + } } const style = { diff --git a/tsconfig.json b/tsconfig.json index 31dbad3b..51b90e79 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,7 @@ "strict": true, "strictBindCallApply": true, "strictFunctionTypes": true, - "strictNullChecks": false, // 150+ errors + "strictNullChecks": true, "strictPropertyInitialization": false, "useUnknownInCatchVariables": true, "noImplicitAny": false, // 300+ errors