When running sonar-scanner, I’m seeing lots of these kinds of errors (names redacted):
ERROR: Failed to analyze file [scripts/.../foo.ts]: Cannot read property 'map' of undefined
ERROR: Failed to analyze file [scripts/.../foo.ts]: Cannot read property 'map' of undefined
ERROR: Failed to analyze file [scripts/.../foo.ts]: Cannot read property 'map' of undefined
INFO: 57/1447 files analyzed, current file: scripts/.../foo.ts
ERROR: Failed to analyze file [src/.../foo.ts]: Cannot read property 'map' of undefined
ERROR: Failed to analyze file [src/.../foo.ts]: Cannot read property 'map' of undefined
ERROR: Failed to analyze file [src/.../foo.ts]: Cannot read property 'map' of undefined
INFO: 281/1447 files analyzed, current file: src/.../foo.ts
ERROR: Failed to analyze file [src/.../foo.ts]: Cannot read property 'map' of undefined
ERROR: Failed to analyze file [src/.../foo.ts]: Cannot read property 'map' of undefined
ERROR: Failed to analyze file [src/.../foo.ts]: Cannot read property 'map' of undefined
I’m seeing this for about 50 files in our repo. All of them are TypeScript. I’m not exactly sure what more information you need to debug this, so please let me know.
It doesnt. Logs state You are using version of TypeScript 4.0.2 which is not officially supported; supported versions >=3.2.1 <3.8.0
Were you able to figure out a workaround?
No, I guess we’ll just have to wait for updates. I’ve run into issues with other tools (e.g. @typescript-eslint) that don’t support TypeScript 4 either.
First of all, sorry for the late answer as I see this thread has been open for quite some time now.
Indeed SonarJS doesn’t support TypeScript 4 at the moment (we plan to add support in the following months though). In the meantime, the impact you should expect is simply not to have any analysis performed on files using TypeScript 4 features.
That said, just so we’re sure that this is the root cause of the issue you’re facing, can you confirm that you only have this problem on files that are using TypeScript 4 features? Could you maybe please provide me with a small reproducer file that triggers this issue (maybe in a private message) ?
Thank you for your feedbacks, and welcome to the SonarSource community !
I was not able to reproduce this undefined error using the two code snippets you shared. Since this thread was created a while ago (at the time of a different SonarQube version) and was inactive until very recently, I am going to close it.
In the meantime, I invite you to create another thread to report a bug, this time sharing which SonarQube version you are using as well as a project configuration along with a minimal, reproducible example that I could use to faithfully reproduce the issue you are encountering.