Type 'string | null' is not assignable to type 'string | undefined'.

 Use the non-null assertion operator for example user.name! to resolve it 

Or alternative you can cast it into a more acceptable typed for example 

user.name as string 

Best approach is to use type guard

const username = user.name !== null ? user.name : ''




Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm