Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explicit-function-return-type] Don't report when using an explicit variable type with an arrow function #149

Closed
cheezenaan opened this Issue Jan 27, 2019 · 4 comments

Comments

Projects
None yet
4 participants
@cheezenaan
Copy link

cheezenaan commented Jan 27, 2019

Repro

{
  "extends": ["plugin:@typescript-eslint/recommended"],
  "plugins": ["react"]
}
import * as React from 'react';

interface Props {
    message?: string;
}

export const Hello: React.SFC<Props> = ({ message = 'kiniro-mosaic' }) => (
    <div>{`Hello! ${message}`}</div>;
);

Expected Result

Neither errors nor warnings

Actual Result

7:40  warning  Missing return type on function  @typescript-eslint/explicit-function-return-type

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 1.1.0
@typescript-eslint/parser 1.1.0
eslint-plugin-react 7.12.4
react 16.7.0
react-dom 16.7.0
TypeScript 3.2.4
ESLint 5.12.1
node 8.11.3
npm 5.6.0

@bradzacher bradzacher changed the title [explicit-function-return-type] Show warnings when using React.SFC [explicit-function-return-type] Don't report when using an explicit variable type with an arrow function Jan 27, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 12, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 12, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 12, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 12, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 14, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 14, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 15, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 16, 2019

gilbsgilbs added a commit to gilbsgilbs/typescript-eslint that referenced this issue Feb 16, 2019

@codepunkt

This comment has been minimized.

Copy link

codepunkt commented Feb 19, 2019

Is this the same problem?

type Wat = () => string[]

// Missing return type on function.eslint(@typescript-eslint/explicit-function-return-type)
let fn: Wat = () => {
  return []
}
type Wat = () => string[]

// no errors or warnings
let fn: Wat
fn = () => {
  return []
}
@gilbsgilbs

This comment has been minimized.

Copy link
Contributor

gilbsgilbs commented Feb 19, 2019

@codepunkt Yes.

@codepunkt

This comment has been minimized.

Copy link

codepunkt commented Feb 19, 2019

@gilbsgilbs can i help?

@gilbsgilbs

This comment has been minimized.

Copy link
Contributor

gilbsgilbs commented Feb 19, 2019

@codepunkt I don't think so. I already made a PR that adds an option to ignore this rule when the function expression is typed. Just need to wait for merge and release.

bradzacher added a commit that referenced this issue Mar 21, 2019

feat(eslint-plugin): allow explicit variable type with arrow functions (
#260)

Fixes #149 

Not sure if this is really acceptable though. Please tell me if it has some edge cases I didn't see or if it's just too broad.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.