user10235687
user10235687

Reputation:

Angular gives an error when use safe navigation operator

I have used a safe navigation operator in my code.

enter image description here

But angular gives an error when I execute the code.

enter image description here

enter image description here

Why this error: Because typescript takes it's a ternary operator ?:: but I used it as a safe navigation operator. So how to solve this Issue?

version: "typescript": ~2.9.2, Angular: 6

Upvotes: 0

Views: 589

Answers (1)

Alireza Ahmadi
Alireza Ahmadi

Reputation: 9903

Based on this Optional chaining only supported as of TypeScript 3.7 or later.

So you need to update your typescript version or use traditional way of checking null:

if($event && $event.actionField && $event.actionField.toLowerCase()=="..."){}

Upvotes: 1

Related Questions