obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
661 stars 95 forks source link

Type of response for `GetRecordingStatus` leads to a possible undefined `recordingFilename` and `recordTimecode` #276

Open florianpasteur opened 2 years ago

florianpasteur commented 2 years ago

Description:

Hi,

According to the documentation when getting the GetRecordingStatus, if OBS is recording both recordTimecode and recordingFilename properties should be populated. With the current type definition the both properties can be undefined and throw a type error, see the following snippet of code.

import OBSWebSocket from "obs-websocket-js";

const obs = new OBSWebSocket();

obs.send("GetRecordingStatus").then(status => {
    if (status.isRecording) {
        // TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
        // Type 'undefined' is not assignable to type 'string'.
        fnWithMandatoryString(status.recordingFilename);
    }
})

function fnWithMandatoryString(someString: string) {
    // whatever
}

Versions Used (if applicable):