Any occurrence of as operator gives [eslint] [E] Parsing error: Unexpected token, expected ";" pointing to the place of as. Example code:
{error && <small className="invalid-feedback">{(error as any).message}</small>}
This cast to any is a workaround to some bug in react-hooks-form's useFormContext function.
When I ignore the error and compile the app it works fine.
This happens in a standard unejected Create React App with latest TypeScript and react-scripts:
$ npm list -dev -depth 0
[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
AFAIK there are no configuration files besides autogenerated tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"src"
]
}
Any ideas why this happens?