Disclaimer: This is a "good programming practices" question rather than a "fix my broken code" question.
Environment
Angular 5.2.9, Angular Material 5.2.4, Typescript 2.4.2, Rxjs 5.5.8
Issue
I am using the mat-dialog component of the angular material library, and subscribing to the observable returned from afterClosed(). Inside of that subscription I have a simple if statement. If value is returned, return value, otherwise return null. My tslint is throwing a fit about returning from inside the async subscription. The exact error is, "TS2355: A function whose declared type is neither 'void' nor 'any' must return a value."
Code
private openModal() : string {
    // some setup code
    this.dialog.open(MyModalComponent, configModal)
        .afterClosed()
        .subscribe(( data : string ) => {
            if ( data ) {
                return data;
            } else {
                return null;
            }
        });
    // cant put return here,  this will execute before modal returns data
}
Question
I want to specify a return type 'string' to my function, but that means I need to do the actual return from within the synchronous function openModal(), and not the async code inside the subscription. I am open to all suggestions on how to improve this code. Thanks!
 
    