Skip to content

The default TypeScript template does not work well with the default ESLint recommendations #9004

@basarat

Description

@basarat

Describe the bug

Setup:

npx create-react-app example --template typescript 
cd example
npm i eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react

With .eslintrc.js:

module.exports = {
  root: true,
  parser: '@typescript-eslint/parser',
  plugins: [
    '@typescript-eslint',
  ],
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:react/recommended'
  ],
  'settings': {
    'react': {
      'version': 'detect'
    },
  }
};

Expected behavior

No errors.

Actual behavior

Error: Missing return type on function.

Shown below:

image

Suggested fix:

Change function App() { to const App: React.FC = () => {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions