-
-
Notifications
You must be signed in to change notification settings - Fork 924
Closed
Copy link
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
1.50.0
What command did you run?
oxlint --type-aware repro/oxlint-ignore-type-refs.ts
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
Minimal config (verified to reproduce):
What happened?
With ignoreTypeReferences: true, type-only references (e.g. in as TypeName casts) should be ignored by no-use-before-define. However, when a variable has the same name as a type, oxlint incorrectly treats the type reference as a variable reference.
Repro steps:
- Create a
.tsfile with the code below - Create
.oxlintrc.jsonwith the config above - Run
oxlint --type-aware -c .oxlintrc.json <file>.ts
declare global {
type foo = string
}
export function fn(x: unknown) {
const foo = x as foo // 'as foo' is a type reference, not variable
return foo
}Expected: No error. The as foo is a type-only reference and should be ignored per ignoreTypeReferences: true.
Actual: Oxlint reports:
eslint(no-use-before-define): 'foo' was used before it was defined.
const foo = x as foo
^^^ ^^^
| `-- used here
`-- defined here
Oxlint conflates the type foo (in as foo) with the variable foo being declared, treating the type assertion as a use of the variable before its definition.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
Type
Fields
Give feedbackPriority
None yet
Effort
None yet
{ "rules": { "no-use-before-define": ["error", { "ignoreTypeReferences": true, "variables": true }] } }