I am developing an Android app in Ionic Angular with Firebase. yesterday i had this problem in VSC and as much as I search I can't find the solution.
this is the Ts from my page Register users
The problem is in the Line 41 "const id = res.user.uid; "
Help me please!.
I try to change const id = res.user.uid; to const id = res.user?.uid; but doesnt works
CodePudding user response:
try to initialize your variable and make sure it's not null. if it was not enough and you are sure that variable (like user
) won't be null, you can try
const id = res.user!.uid;
or you can suppress the error by adding this line in the right behind the part of your code with the error:
// @ts-ignore: Object is possibly 'null'.
or you can generally disable null checking in your project in tsconfig.json
file (which is not recommended) like this:
"compilerOptions": {
...
"strictNullChecks": false
},