Skip to content

Imported modules only used as type annotation are marked as no-unused-vars #5

Closed
@doits

Description

@doits

Thanks for the latest update to v5! If just tried it out and it works fine, though I know have another problem which I don't exactly know if estlint-config-typescript introduced it or something else ...

My config looks like this:

    "extends": [
      "eslint:recommended",
      "plugin:vue/recommended",
      "plugin:jest/recommended",
      "@vue/eslint-config-typescript",
      "@vue/eslint-config-prettier"
    ],

Now in my .vue files if I do this, I get a no-unused-vars error:

...
import { Location } from "vue-router/types"

export default Vue.extend({
  ...
  methods: {
    getLocation(): Location {
      return { name: "some_location" }
    }
  }
})

// => no-unused-vars: 'Location' is defined but never used

The key points are:

  • Location is only imported because it is used as a type annotation
  • Location is never explicitly used but as the return type of the method
  • Other imports work fine which are used inside methods or computed getters beside type annotation

I didn't have this before upgrading to v5, but a lot of things changed during that upgrade (new peer dependencies, other packages upgraded) so I'm sorry if this is the wrong place to report it.

Is this something that can be fixed here or elsewhere?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions