Hi! Can't understand why.
CLI:
tslint -c tslint.json --type-check --project tsconfig.json src/app.tsx
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"dom",
"es2015"
],
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true
}
}
import * as React from 'react';
export class App extends React.Component<{}, {}> {
public render(): JSX.Element {
return <span/>;
}
}
with tslint.json configuration:
{
"rules": {
"no-unsafe-any": true
}
}
Error
ERROR: app.tsx[5, 17]: Unsafe use of expression of type 'any'.
No errors
Do you have @types/react installed? Are there any tsc errors when you compile your project with --noImplicitAny?
@adidahiya
Do you have
@types/reactinstalled
yes
npm ls @types/react
...
└── @types/[email protected]
Are there any
tscerrors when you compile your project with--noImplicitAny?
no
I have the same problem
Can you try to repro this with the latest TSLint? We've had various refactorings occur since 5.5.0.
It's still reproducible (in my case)
The same problem
This was fixed by #3699. 🎉
For anyone that finds this in the future. I was struggling with this for over an hour while configuring eslint. After adding the types with yarn add -D @types/react @types/react-dom I was still getting an error on the return statement. This was fixed by simply reloading/restarting vscode. Save yourself some time and use F1 -> Reload Window.
🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖
🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋
Most helpful comment
I have the same problem