How to check null on interface variable and how to set the default value in typescript?
const userModel = snap.data() as UserModel //firestore
export interface UserModel {
docId: string,
accountId: number // if null then I want to set 0
}
Sometimes, users don't have the account id. So how do I check it?
if (userModel.userPushToken !== undefined)
- Currently I am checking like this