I'm trying to get a screen to stream to my Angular 5 Electron app. I'm using the desktopCapturer provided by Electron. This is my code:

```
loadCurrentScreensource() {
    desktopCapturer.getSources({
        types: [
          'window',
          'screen'
        ]
     }, (error, sources) => {
        if (error) {
          throw error;
        }
        console.log('Finding screen: ' + this.selectedScreenSource);
        console.log(sources);

        for (let i = 0; i < sources.length; ++i) {
          if (sources[i].id === this.selectedScreenSource.id) {
            console.log('Found screen');

            const constraints = {
              audio: false,
              video: {
                mandatory: {
                  chromeMediaSource: 'desktop',
                  chromeMediaSourceId: sources[i].id,
                  minWidth: 1280,
                  maxWidth: 1280,
                  minHeight: 720,
                  maxHeight: 720
                }
              }
            };

            navigator.mediaDevices.getUserMedia(constraints)
              .then((stream) => this.handleStream(stream))
              .catch((e) => this.handleError(e));
            return;
          }
        }
      }
    );
}

```

According to the documentation [here](https://electronjs.org/docs/api/desktop-capturer), I need to use the mandatory part of the constraints to get the correct stream. However, TypeScript gives me the error that the types of property 'video' are incompatible. If I enter the following constraints I sometimes get a stream of my webcam:

```
{ width: 1280, height: 720 }

```

The docs at [mozzilla.org](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) never mention the mandatory part, so I guess I overlooked some import or something to get getUserMedia to accept my constraints. Either that, or maybe getUserMedia has been changed, but the docs didn't?

What am I doing wrong here?

**[edit]**

Also, the documentation for [MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) does not have the mandatory, nor the chromeMediaSourceId properties. This is however, the same documentation that Electron links to.

**[edit2]**

I found the [deviceId](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/deviceId) constraint, which I previously overlooked. When I use the following constraints, I still get the webcam stream though.

```
video: {
  width: 1280,
  height: 720,
  deviceId: this.selectedScreenSource.id
}

```