Sometimes you will get the return value type string | null from function, then reassign the return value to a string type value. And the typescript will show the type error.
Example
const language: string = localStorage.getItem('language'); // type error
Cast
const language: string = (localStorage.getItem('language') || '').toString();