SonarSource / SonarTS

Static code analyzer for TypeScript
GNU Lesser General Public License v3.0
761 stars 53 forks source link

SonarTS doesn't understand newest TS lang features, concretely: optional chaining operator #904

Closed abelepereira closed 4 years ago

abelepereira commented 4 years ago

I want to report a bug.

SonarTS version: 2.1
Node.js version: 14
TypeScript version: 3.8.3

Rule key: typescript:S905: Expected an assignment or function call and instead saw an expression.

Reproducer

foo?.bar(); // False-positive here: got "Expected an assignment or function call and instead saw an expression."

Expected behavior

Should simply understand the new (since TS v3.7) TS optional chaining operator (?.), and don't flag it as a bug.

ed-graham commented 4 years ago

Interestingly, this works for the SonarLint plug-in inside VS Code - no error is reported. However, the SonarQube analysis fails with the error Failed to parse file ... at line ... Expression expected.

vilchik-elena commented 4 years ago

Since SonarTS 2.0 typescript code is analyzed by SonarJS (SonarTS is basically empty plugin). I will close this issue and review the problem in https://github.com/SonarSource/SonarJS/issues/1990