eslint / typescript-eslint-parser

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
Other
915 stars 75 forks source link

Incorrect no-use-before-define #550

Closed renchap closed 5 years ago

renchap commented 5 years ago

What version of TypeScript are you using? 3.1.3

What version of typescript-eslint-parser are you using? 21.0.0

What code were you trying to parse?

function test(file: Blob) {
  const slice: typeof file.slice =
    file.slice || (file as any).webkitSlice || (file as any).mozSlice
  return slice
}

What did you expect to happen? No error should be in eslint output

What happened?

  41:28  error  'slice' was used before it was defined  no-use-before-define

This worked fine with typescript-eslint-parser@20.0.0. file.slice is defined, as file is a Blob argument. I think the parser mistakes it with the const slice.

mysticatea commented 5 years ago

Thank you for the report.

I confirmed it. I will work on this.