Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-unsafe-any with tsx throwing error #3080

Closed
tyv opened this issue Jul 28, 2017 · 9 comments
Closed

no-unsafe-any with tsx throwing error #3080

tyv opened this issue Jul 28, 2017 · 9 comments

Comments

@tyv
Copy link

tyv commented Jul 28, 2017

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        
  }
}

Bug Report

  • TSLint version: 5.5.0
  • TypeScript version: 2.4.2
  • Running TSLint via: CLI

TypeScript code being linted

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
    }
}

Actual behavior

Error

ERROR: app.tsx[5, 17]: Unsafe use of expression of type 'any'.

Expected behavior

No errors

@adidahiya
Copy link
Contributor

Do you have @types/react installed? Are there any tsc errors when you compile your project with --noImplicitAny?

@tyv
Copy link
Author

tyv commented Aug 2, 2017

@adidahiya

Do you have @types/react installed

yes

npm ls @types/react
...
└── @types/react@15.6.0

Are there any tsc errors when you compile your project with --noImplicitAny?

no

@Nitive
Copy link

Nitive commented Aug 15, 2017

I have the same problem

review-squirrel pushed a commit to eclipsesource/generator-tabris-js that referenced this issue Sep 25, 2017
There is an issue with using this rule with JSX syntax. See [1].

[1]: palantir/tslint#3080

Change-Id: I5ec1df9fabd1fa5ba12c15c37ff685f4e5ec55f8
@adidahiya
Copy link
Contributor

Can you try to repro this with the latest TSLint? We've had various refactorings occur since 5.5.0.

@Ailrun
Copy link

Ailrun commented Nov 6, 2017

It's still reproducible (in my case)

@bahkostya
Copy link

The same problem

@JoshuaKGoldberg
Copy link
Contributor

This was fixed by #3699. 🎉

@JoePotentier
Copy link

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.

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants