I've encountered a dilemma while attempting to convert several JS files with double question marks to TypeScript using tsc.
Unfortunately, the tsc compiler does not recognize ??.
For example: this.x = typeof params.x == "string" ? this._processStringParam(params.x, "x") : params.x ?? 0;
This results in the error message: imageElement.js:70:96 - error TS1109: Expression expected. this.x = typeof params.x == "string" ? this._processStringParam(params.x, "x") : params.x ?? 0;
I am puzzled by the fact that the presence of double question marks is the main motivation for converting to TS. So, why fix it in JS before running through tsc?
What is the best approach to convert these js files to TypeScript then?
The tsconfig.json file appears as follows:
{
"compilerOptions": {
"checkJs": false,
"module": "commonjs",
"target": "ES5",
"allowJs": true,
"rootDir": "./",
"baseUrl": "./",
"outDir": "./build",
"noStrictGenericChecks": true,
"skipLibCheck": true,
"strictFunctionTypes": false,
"lib": [
"es2015",
"dom"
]
},
"exclude": [
"./build/**"
]
}