title: Not all code paths return a value in Typescript and Angular 9
body: <p>I am building a small project and I am basically dealing with registration and authentication using <code>Express</code> and <code>Angular 9</code>.
  Everything was going well when I got the error <code>Not all code paths return a value</code> in the file <strong>register.component.ts</strong> and was not able to understand what is missing in that typescript file.</p>
  <p><strong>validate.service.ts</strong></p>
  <pre><code>import { Injectable } from '@angular/core';
  
  @Injectable({
    providedIn: 'root'
  })
  export class ValidateService {
  
    constructor() { }
  
    validateRegister(user) {
      if(user.name == undefined || user.email == undefined || user.password == undefined) {
        return false;
      } else {
        return true;
      }
    }
  
    validateEmail(email) {
      // operations ...
    }
  }
  </code></pre>
  <p><strong>register.components.ts</strong></p>
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { ValidateService } from '../../services/validate.service';
  import { FlashMessagesService } from 'angular2-flash-messages';
  
  @Component({
    selector: 'app-register',
    templateUrl: './register.component.html',
    styleUrls: ['./register.component.css']
  })
  export class RegisterComponent implements OnInit {
  
    name!: String;
    username!: String;
    email!: String;
    password!: String;
  
    constructor(private validateService: ValidateService, private flashMessage: FlashMessagesService) { }
  
    ngOnInit(): void {
    }
  
    onRegisterSubmit() {
      const user = {
        name: this.name,
        username: this.username,
        email: this.email,
        password: this.password
      }
  
      // Required fields
      if(!this.validateService.validateRegister(user)) {
        this.flashMessage.show('Please fill in all fields', {cssClass: 'alert-danger', timeout: 3000});
        return false;
      }
  
      // Required fields
      if(!this.validateService.validateEmail(user.email)) {
        this.flashMessage.show('Please fill in all fields', {cssClass: 'alert-danger', timeout: 3000});
        return false;
      } else console.log('Correct');
    }
  }
  </code></pre>
  <p>Finally on the <strong>register.components.html</strong> I am passing the <code>onRegisterSubmit()</code>:</p>
  <pre><code>&lt;h2 class=&quot;page-header&quot;&gt;Register&lt;/h2&gt;
   &lt;form (submit)=&quot;onRegisterSubmit()&quot;&gt;
    &lt;div class=&quot;form-group&quot;&gt;
     &lt;label&gt;Name&lt;/label&gt;
     &lt;input type=&quot;text&quot; [(ngModel)]=&quot;name&quot; name=&quot;name&quot; class=&quot;form-control&quot;&gt;
    &lt;/div&gt;
   &lt;/form&gt;
  </code></pre>
  <p>The problem seems to lie on the <strong>register.component.ts</strong> file as something seems to be missing.
  Initially I thought I could be a non correct initialization problem but I could not find anything. I also went thought <a href="https://stackoverflow.com/questions/43064221/typescript-ts7006-parameter-xxx-implicitly-has-an-any-type">this post</a> which was useful to evaluate an additional option. However that didn't solve the problem. I appreciate anyone how could possibly point me to the solution.</p>