title: Type 'string | null' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'
body: <p>When i make property as id!:string; or id:string=''; when i assign the value of params i get an error</p>
  <p>(property) MoreParametersComponent.id: string
  ts(2322)Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.</p>
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { ActivatedRoute } from '@angular/router';
  
  @Component({
    selector: 'app-more-parameters',
    templateUrl: './more-parameters.component.html',
    styleUrls: ['./more-parameters.component.css']
  })
  export class MoreParametersComponent implements OnInit {
    id!: string; // or id:string='';
    id2:number=0;
    constructor(private activatedRoute:ActivatedRoute) { }
  
    ngOnInit(): void {
      this.activatedRoute.paramMap.subscribe(params=&gt;{
        this.id=params.get('id'); // gives the above error here
        this.id2=parseInt(params.get('id2'));//error
      });
    }
  
  }
  </code></pre>
  <p>How do I get around this error?</p>
  <p>My Rest of the Code:</p>
  <p>app.component.html</p>
  <pre><code>&lt;a routerLink=&quot;&quot;&gt; Home &lt;/a&gt;&lt;br&gt;
  &lt;a routerLink=&quot;one-parameter,'p01'&quot;&gt; One-Parameter &lt;/a&gt;&lt;br&gt;
  &lt;a routerLink=&quot;more-parameter,{id:'p02',id2:123}&quot;&gt; More-Parameter &lt;/a&gt; 
  &lt;br&gt;&lt;br&gt;
  &lt;router-outlet&gt;&lt;/router-outlet&gt;
  &lt;br&gt;&lt;br&gt;
  </code></pre>
  <p>Route.config.ts</p>
  <pre><code>import { Routes } from '@angular/router'
  import { HomeComponent } from './home/home.component';
  import { MoreParametersComponent } from './more-parameters/more-parameters.component';
  import { OneParamterComponent } from './one-paramter/one-paramter.component';
  
  
  export const mainroute:Routes=[
      {path:'',component:HomeComponent},
      {path:'one-parameter',component:OneParamterComponent},
      {path:'more-parameter',component:MoreParametersComponent}
  ];
  </code></pre>