Skip to content

Commit

Permalink
fix(typescript): type checks on selectedTextTrack, selectedAudioTrack…
Browse files Browse the repository at this point in the history
…, selectedVideoTrack (#3910)

* Fix type checks on selectedTextTrack and selectedAudioTrack

* Improve logging

* Rename variable for clarity

* Apply same fix to selectedVideoTrack

* Lint fixes

* Update src/Video.tsx

Co-authored-by: Olivier Bouillet <62574056+freeboub@users.noreply.github.com>

* Update src/Video.tsx

Co-authored-by: Olivier Bouillet <62574056+freeboub@users.noreply.github.com>

* Update src/Video.tsx

Co-authored-by: Olivier Bouillet <62574056+freeboub@users.noreply.github.com>

---------

Co-authored-by: Krzysztof Moch <krzysmoch.programs@gmail.com>
Co-authored-by: Olivier Bouillet <62574056+freeboub@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 19, 2024
1 parent 87e7f42 commit dc2a2ab
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,16 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!selectedTextTrack) {
return;
}
const type = typeof selectedTextTrack.value;
if (type !== 'number' && type !== 'string') {
console.log('invalid type provided to selectedTextTrack');
const typeOfValueProp = typeof selectedTextTrack.value;
if (
typeOfValueProp !== 'number' &&
typeOfValueProp !== 'string' &&
typeOfValueProp !== 'undefined'
) {
console.warn(
'invalid type provided to selectedTextTrack.value: ',
typeOfValueProp,
);
return;
}
return {
Expand All @@ -208,9 +215,16 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!selectedAudioTrack) {
return;
}
const type = typeof selectedAudioTrack.value;
if (type !== 'number' && type !== 'string') {
console.log('invalid type provided to selectedAudioTrack');
const typeOfValueProp = typeof selectedAudioTrack.value;
if (
typeOfValueProp !== 'number' &&
typeOfValueProp !== 'string' &&
typeOfValueProp !== 'undefined'
) {
console.warn(
'invalid type provided to selectedAudioTrack.value: ',
typeOfValueProp,
);
return;
}

Expand All @@ -224,9 +238,16 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!selectedVideoTrack) {
return;
}
const type = typeof selectedVideoTrack.value;
if (type !== 'number' && type !== 'string') {
console.log('invalid type provided to selectedVideoTrack');
const typeOfValueProp = typeof selectedVideoTrack.value;
if (
typeOfValueProp !== 'number' &&
typeOfValueProp !== 'string' &&
typeOfValueProp !== 'undefined'
) {
console.warn(
'invalid type provided to selectedVideoTrack.value: ',
typeOfValueProp,
);
return;
}
return {
Expand Down

0 comments on commit dc2a2ab

Please sign in to comment.