When running a scan of a typescript (v4.4) project, I get a number of parser errors. The error reads:
ERROR: Unable to parse file: file:///path/to/file/file.ts
ERROR: Parse error at line 2 column 11:
The contents of each file are all perfectly valid typescript though e.g.
export default class DOMUtils {
public static windowExists(): boolean {
return typeof window !== 'undefined';
}
}
I’ve tried running both sonar-scanner (v4.5.0.2216) and sonarqube community (v7.9.6) with the same result. my tsconfig is as per the below. In case it’s relevant, this is a React/Next.js project):
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"paths": {
"@components/*": ["components/*"],
"@models/*": ["models/*"],
"@pages/*": ["pages/*"],
"@styles/*": ["styles/*"],
"@tests/*": ["__tests__/*"],
"@utils/*": ["utils/*"]
},
"typeRoots": ["./@types", "node_modules/@types"]
},
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
I’ve tried rolling project back as far as typescript v3.3 to see if it was related to that, which made no difference.
If anyone has any ideas on what the issue might be i’d be hugely greatful, sinking hours/days into this with no progress from the range of parser errors it appears to be tripping up on typescript keywords