Optional chaining in Typescript is reported as an expression

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension): cloud
  • error observed:
export default class Vimeo extends React.Component<Props> {
  constructor(p: Props) {
    this.player = null
  private player: Player | null
  componentWillUnmount() {
// => Expected an assignment or function call and instead saw an expression. Bug, Major, 10min effort
// etc...
  • steps to reproduce: above code

I think your linter doesn’t support “optional chaining” https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining

Hello @haf, thanks for raising this problem.

I believe you are facing the issue already reported on github, you can have a look at it here.

I linked your post there.


Great, I’m going to assume SonarCloud upgrades its parser to support all of TypeScript in due time, so I’m happy with not going any further now.