Conditional Chaining and function calls


I am using SonarCloud JavaScript Analyzer and stumbled upon a behaviour that looks like a bug.
Given the following code, where the variable onChange can either be undefined or a function.

onChange?.(props.values, props.isValid);

We are getting the following error message “Expected an assignment or function call and instead saw an expression.”
Upon investigation it feels like we are facing a different use case and error message than Typescript 3.7.2 Null conditional operator on a function call is giving a false positive

Please let me know if you think an extra config somewhere would help
Thank you

Where do you see this error message?

There is a chance that for analysis you are using version of TypeScript not supporting the optional chaining. Could you share the logs of analysis?

Hi Lena,

Thank you for your message, looking at our logs in the CI build, I can see


Looking further down in tthe logs I can see

INFO: ANALYSIS SUCCESSFUL, you can find the results at:

Are you interested in more details? Happy to share that with you if required

I was asking where do you see this error (is it issue reported on code, or error in logs during analysis or whatever else). But I found myself that it is the rule S905 reporting that.

We already have a ticket for this FP and we are working on it