Create-react-app: TypeScript - Incorrect *no-use-before-define* warning

Created on 5 Jul 2019  Â·  2Comments  Â·  Source: facebook/create-react-app

Describe the bug

Incorrect no-use-before-define warning when using TypeScript.

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

N/A

Environment

System:
  OS: macOS Sierra 10.12.6
  CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Binaries:
  Node: 9.4.0 - ~/.nvm/versions/node/v9.4.0/bin/node
  Yarn: Not Found
  npm: 6.5.0 - ~/.nvm/versions/node/v9.4.0/bin/npm
Browsers:
  Chrome: 75.0.3770.100
  Firefox: 65.0.1
  Safari: 12.1.1
npmPackages:
  react: ^16.8.6 => 16.8.6
  react-dom: ^16.8.6 => 16.8.6
  react-scripts: ^3.0.1 => 3.0.1
npmGlobalPackages:
  create-react-app: Not Found

Steps to reproduce

  1. Run npx create-react-app my-app --typescript
  2. Open / create a .tsx file and write the code below:
type Foo = ReturnType<typeof bar>
const bar = (): string => 'baz';
  1. Run react-scripts start command.

Expected behavior

Should emit all files without any warning.

Actual behavior

Line 11:  'bar' was used before it was defined  no-use-before-define

Reproducible demo

See code / example upper.

bug

All 2 comments

Update — Published npm module hasn't the same rules as specified in the Git repository.

eslint-config-react-app (4.0.1) - (fetched via react-scripts)

'no-use-before-define': [
    'warn',
    {
        functions: false,
        classes: false,
        variables: false,
    },
]

/packages/eslint-config-react-app (4.0.1) - GitHub

'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
    'warn',
    {
        functions: false,
        classes: false,
        variables: false,
        typedefs: false
    }
]

Once updated by myself the warning disappeared.

Thanks, a new version should be released soon.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Evan-GK picture Evan-GK  Â·  3Comments

JimmyLv picture JimmyLv  Â·  3Comments

ap13p picture ap13p  Â·  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  Â·  3Comments

alleroux picture alleroux  Â·  3Comments