standard / ts-standard

Typescript style guide, linter, and formatter using StandardJS
https://www.npmjs.com/package/ts-standard
MIT License
473 stars 36 forks source link

Bug: 'variable' is defined but never used (@typescript-eslint/no-unused-vars) but is actually used. #85

Closed theoludwig closed 4 years ago

theoludwig commented 4 years ago

Hey 👋,

I had a bug with ts-standard, I have a file called global.d.ts that look like this :

import { UserRequest } from '../models/User'

declare global {
  namespace Express {
    interface Request {
      user?: UserRequest
    }
  }
}

Where UserRequest is a simple interface, with that setup as I said in the title I've got 'UserRequest' is defined but never used. (@typescript-eslint/no-unused-vars) error, but I shouldn't have this error because I'm actually using it.

For the moment my workaround (not really pretty) is to do something like this :

// eslint-disable-next-line
import { UserRequest } from '../models/User'

Looking forward to discuss the bug, thank you.

toddbluhm commented 4 years ago

So ts-standard is just a wrapper around https://github.com/standard/eslint-config-standard-with-typescript and https://github.com/typescript-eslint/typescript-eslint

This seems like a parsing/linting issue. I would recommend posting your issue on the https://github.com/typescript-eslint/typescript-eslint project where the typescript parser lives.

if you think this might instead be a configuration issue with how ts-standard passes options to eslint, the best way to test that out would be to install eslint, typescript-eslint, and the eslint-config-standard-with-typescript, configure it all manually, and run it to see if the error still exists. If the error is gone, then posting your configuration would be extremely helpful and we can figure out which options need to be passed to eslint from ts-standard 😄

theoludwig commented 4 years ago

As I can see, It's a known issue with typescript-eslint for quite some time : https://github.com/typescript-eslint/typescript-eslint/issues/1856 Apparently the issue will be fixed in the 4.0 release : https://github.com/typescript-eslint/typescript-eslint/pull/2330.

Is ts-standard will upgrade typescript-eslint for the 4.0 version when ready ?

toddbluhm commented 4 years ago

Yes, whenever typescript-eslint releases a new update, ts-standard will be updated appropriately 😄

theoludwig commented 4 years ago

Alright, since it's not really an issue related to ts-standard, I'll close this for now.