Within my Typescript file, I have the following line:
return stringToValidate.length <= maxLength;
Despite the code executing without issues, an error is displayed: TS2339: Property 'length' does not exist on type 'string'.
I am curious about the origin of this issue and how to resolve it. Below is my tsconfig.json configuration:
{
"compilerOptions": {
"target": "ES2021",
"lib": [
"ES2021"
],
"module": "CommonJS",
"moduleResolution": "node",
"strict": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUncheckedIndexedAccess": true,
"noUnusedParameters": true,
"alwaysStrict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"resolveJsonModule": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"rootDir": "./src",
"sourceMap": true,
"inlineSources": false
}
}