Closed
Description
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 |
Activity
[-][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[/+]feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
feat(eslint-plugin): allow explicit variable type with arrow functions
7 remaining items
feat(eslint-plugin): allow explicit variable type with arrow functions (
saranshkataria commentedon Mar 27, 2019
I see the latest changes have been published, but I still get an error when writing this:
const App: React.FunctionComponent<{}> = () => <div>Hello World</div>;
gilbsgilbs commentedon Mar 27, 2019
@saranshkataria thanks. I think it was only released as alpha at the moment. Just to be sure:
allowTypedFunctionExpressions
option on the rule? See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md#allowtypedfunctionexpressionsbradzacher commentedon Mar 27, 2019
Yup, as @gilbsgilbs mentioned, this is only on the automatically released canary tag right now.
yarn add @typescript-eslint/eslint-plugin@canary
In future, please keep an eye on the releases section of the repo to see if PRs have released.
https://github.com/typescript-eslint/typescript-eslint/releases
saranshkataria commentedon Mar 27, 2019
bradzacher commentedon Mar 28, 2019
kkalavantavanich commentedon Apr 18, 2019
gilbsgilbs commentedon Apr 18, 2019
TidyIQ commentedon May 2, 2019
TidyIQ commentedon May 2, 2019
Nevermind, I just saw this issue that explains it. For anyone following along, the rule posted further up in the comments is incorrect. It should be:
ben-xD commentedon Aug 11, 2019
May I ask why we need to set a rule for this? What is the alternative, and why don't we have it ignore missing return types for react components by default?