title: Angular error TS2564: Property 'users' has no initializer and is not definitely assigned in the constructor
body: <p>I am using angular to built this app using this example from &quot;<a href="https://coursetro.com/posts/code/171/Angular-7-Tutorial---Learn-Angular-7-by-Example" rel="noreferrer">https://coursetro.com/posts/code/171/Angular-7-Tutorial---Learn-Angular-7-by-Example</a>&quot;.<br />
  Its an exact code but I am still getting an error for <strong>&quot;user:Object&quot;</strong></p>
  <p><strong>How can I fix this error?</strong></p>
  <blockquote>
  <p>error TS2564: Property 'users' has no initializer and is not
  definitely assigned in the constructor.</p>
  <p>12   users: Object;
  ~~~~~</p>
  </blockquote>
  <pre><code>Here is the exact code as per website:
  import { Component, OnInit } from '@angular/core';
  import { DataService } from '../data.service';
  
  @Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.scss']
  })
  export class HomeComponent implements OnInit {
    //h1Style:boolean = false;
  
    users: Object;
  
    constructor(private data: DataService) { }
  
    ngOnInit(): void {
      this.data.getUsers().subscribe(data =&gt; {
          this.users = data
          console.log(this.users);
        }
      );
    }
  
  
  }
  </code></pre>
  <p>My Angular based on ng version:
  Angular CLI: 11.1.2</p>
  <p>Node: 14.15.4</p>
  <p>OS: win32 x64</p>
  <p>Angular: 11.1.1</p>
  <p>... animations, common, compiler, compiler-cli, core, forms</p>
  <p>... platform-browser, platform-browser-dynamic, router</p>
  <p>Ivy Workspace: Yes</p>
  <p>Package                         Version</p>
  <hr />
  <p>@angular-devkit/architect       0.1101.2</p>
  <p>@angular-devkit/build-angular   0.1101.2</p>
  <p>@angular-devkit/core            11.1.2</p>
  <p>@angular-devkit/schematics      11.1.2</p>
  <p>@angular/cli                    11.1.2</p>
  <p>@schematics/angular             11.1.2</p>
  <p>@schematics/update              0.1101.2</p>
  <p>rxjs                            6.6.3</p>
  <p>typescript                      4.1.3</p>