basst314 / ngx-webcam

A simple Angular webcam component / pure & minimal, no flash-fallback
https://basst314.github.io/ngx-webcam/?
MIT License
231 stars 104 forks source link

Not all code paths return a value #141

Open jbistis opened 2 years ago

jbistis commented 2 years ago

angular/cli 13.1.2 / typescript 4.5.4 / ngx-webcam 0.4.1 Getting 2 errors: webcam.component.ts:151:6 - error TS7030: Not all code paths return a value. private static getDeviceIdFromMediaStreamTrack( mediaStreamTrack: MediaStreamTrack ): string { if ( mediaStreamTrack.getSettings && mediaStreamTrack.getSettings() && mediaStreamTrack.getSettings().deviceId ) { return mediaStreamTrack.getSettings().deviceId; } else if ( mediaStreamTrack.getConstraints && mediaStreamTrack.getConstraints() && mediaStreamTrack.getConstraints().deviceId ) { const deviceIdObj: ConstrainDOMString = mediaStreamTrack.getConstraints().deviceId; return WebcamComponent.getValueFromConstrainDOMString(deviceIdObj); } }

webcam.component.ts:178:6 - error TS7030: Not all code paths return a value. private static getFacingModeFromMediaStreamTrack( mediaStreamTrack: MediaStreamTrack ): string { if (mediaStreamTrack) { if ( mediaStreamTrack.getSettings && mediaStreamTrack.getSettings() && mediaStreamTrack.getSettings().facingMode ) { return mediaStreamTrack.getSettings().facingMode; } else if ( mediaStreamTrack.getConstraints && mediaStreamTrack.getConstraints() && mediaStreamTrack.getConstraints().facingMode ) { const facingModeConstraint: ConstrainDOMString = mediaStreamTrack.getConstraints().facingMode; return WebcamComponent.getValueFromConstrainDOMString( facingModeConstraint ); } } }

basst314 commented 2 years ago

Hi @jbistis, this sounds like an issue caused by your linter. Can you share what linter you're using (e.g. ESLint) and if you have applied any specific rules (e.g. 'consistent-return')? Thanks

jbistis commented 2 years ago

Yes, thanks. The update was to set "noImplicitReturns": false per https://stackoverflow.com/questions/51446242/how-to-fix-the-issue-not-all-the-code-paths-return-value