Skip to content

[no-use-before-define]: typedefs option doesn't work #249

Closed
@Hotell

Description

@Hotell

Repro

{
  "rules": {
    "typescript/no-use-before-define": ["error",{"typedefs": true}]
  }
}
// Should error according to docs, but it wont

let myVar: StringOrNumber = 'hello'
type StringOrNumber = string | number

Expected Result

Should work according to docs

Actual Result

Doesn't work at all

Additional Info

Also dunno if this is considered within the implementation, but there is a common pattern in React to get Props/State types from implementation by leveraging typeof. So if typedefs is set to false this should not raise any error:

type State = typeof initialState
const initialState = { count: 0, who: ''}

Versions

package version
@typescript-eslint/eslint-plugin 1.3.0
@typescript-eslint/parser X.Y.Z
TypeScript 3.3.3
ESLint 5.12
node 8.15
npm X.Y.Z

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginscope analyserIssues that are caused by bugs/incomplete cases in the scope analyser

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions