1
votes

I can't figure out why this doesn't work. I would expect @typescript-eslint/no-unused-vars to recognize the type as being used for this function return type. What am I doing wrong? Am I miss-understanding how this is supposed to work?

enter image description here

Code from the image:

.eslintrc.json

{
    "env": {
        "browser": false,
        "node": true
    },
    "extends": [
        "airbnb-base",
        "eslint:recommended",
        "plugin:@typescript-eslint/eslint-recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 2020,
        "sourceType": "module"
    },
    "plugins": [
        "typescript",
        "@typescript-eslint"
    ],
    "settings": {
        "import/resolver": {
            "typescript": {}
        }
    },
    "rules": {
        "no-unused-vars": "off",
        "@typescript-eslint/no-unused-vars": ["error"]
    }
}

Service.ts:

export declare interface FooConfig {}

Foo.ts:

import { FooConfig } from "library/types/Service";

export default function foo(): FooConfig {

    return {};

}

Error:

ESLint: 'FooConfig' is defined but never used. (@typescript-eslint/no-unused-vars)

1

1 Answers

0
votes

Looks like this is a known issue for the version I'm using (4.0.0-alpha.1) and will hopefully be fixed soon.

https://github.com/typescript-eslint/typescript-eslint/issues/2337