Skip to content

[no-unnecessary-type-arguments] false positives after upgrading from 5.11.0 to 5.12.0 #4554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
doberkofler opened this issue Feb 14, 2022 · 6 comments · Fixed by #4555
Closed
3 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@doberkofler
Copy link
Contributor

doberkofler commented Feb 14, 2022

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "env": {
    "es6": true
  },
  "globals": {},
  "parser": null,
  "parserOptions": {
    "ecmaVersion": 2017,
    "sourceType": "script"
  },
  "plugins": [],
  "rules": {
    "accessor-pairs": [
      "warn"
    ],
    "array-bracket-newline": [
      "off"
    ],
    "array-bracket-spacing": [
      "warn",
      "never"
    ],
    "array-callback-return": [
      "warn"
    ],
    "arrow-spacing": [
      "warn",
      {
        "before": true,
        "after": true
      }
    ],
    "block-spacing": [
      "warn",
      "never"
    ],
    "brace-style": [
      "warn",
      "1tbs"
    ],
    "camelcase": [
      "warn",
      {
        "properties": "never",
        "ignoreDestructuring": false,
        "ignoreImports": false,
        "ignoreGlobals": false
      }
    ],
    "comma-spacing": [
      "warn",
      {
        "before": false,
        "after": true
      }
    ],
    "comma-style": [
      "warn",
      "last"
    ],
    "complexity": [
      "warn",
      30
    ],
    "computed-property-spacing": [
      "warn",
      "never"
    ],
    "consistent-this": [
      "warn",
      "that"
    ],
    "consistent-return": [
      "warn"
    ],
    "constructor-super": [
      "error"
    ],
    "curly": [
      "error",
      "all"
    ],
    "default-case": [
      "error"
    ],
    "default-case-last": [
      "warn"
    ],
    "default-param-last": [
      "warn"
    ],
    "dot-notation": [
      "error",
      {
        "allowPattern": "^[a-zA-Z]+(_[a-zA-Z]+)+$",
        "allowKeywords": true
      }
    ],
    "eol-last": [
      "warn"
    ],
    "eqeqeq": [
      "error"
    ],
    "func-call-spacing": [
      "warn",
      "never"
    ],
    "func-names": [
      "off"
    ],
    "func-style": [
      "off"
    ],
    "function-paren-newline": [
      "warn",
      "multiline"
    ],
    "generator-star-spacing": [
      "warn",
      {
        "before": true,
        "after": false
      }
    ],
    "guard-for-in": [
      "error"
    ],
    "grouped-accessor-pairs": [
      "warn"
    ],
    "id-blacklist": [
      "off"
    ],
    "id-length": [
      "off"
    ],
    "id-match": [
      "off"
    ],
    "implicit-arrow-linebreak": [
      "warn"
    ],
    "indent": [
      "warn",
      "tab",
      {
        "SwitchCase": 1,
        "flatTernaryExpressions": false,
        "offsetTernaryExpressions": false,
        "ignoreComments": false
      }
    ],
    "jsx-quotes": [
      "warn",
      "prefer-double"
    ],
    "key-spacing": [
      "warn",
      {
        "beforeColon": false,
        "afterColon": true
      }
    ],
    "keyword-spacing": [
      "error",
      {
        "before": true,
        "after": true,
        "overrides": {}
      }
    ],
    "linebreak-style": [
      "off"
    ],
    "lines-around-comment": [
      "off"
    ],
    "lines-between-class-members": [
      "warn",
      "always",
      {
        "exceptAfterSingleLine": true
      }
    ],
    "max-depth": [
      "warn",
      10
    ],
    "max-len": [
      "warn",
      500
    ],
    "max-lines": [
      "warn",
      1000
    ],
    "max-nested-callbacks": [
      "warn",
      10
    ],
    "max-params": [
      "warn",
      10
    ],
    "max-statements": [
      "warn",
      150
    ],
    "max-statements-per-line": [
      "warn",
      {
        "max": 2
      }
    ],
    "new-cap": [
      "warn"
    ],
    "new-parens": [
      "warn"
    ],
    "newline-per-chained-call": [
      "off"
    ],
    "no-alert": [
      "off"
    ],
    "no-array-constructor": [
      "warn"
    ],
    "no-await-in-loop": [
      "warn"
    ],
    "no-bitwise": [
      "warn"
    ],
    "no-caller": [
      "error"
    ],
    "no-case-declarations": [
      "error"
    ],
    "no-class-assign": [
      "error"
    ],
    "no-confusing-arrow": [
      "error"
    ],
    "no-continue": [
      "warn"
    ],
    "no-const-assign": [
      "error"
    ],
    "no-constructor-return": [
      "warn"
    ],
    "no-delete-var": [
      "error"
    ],
    "no-div-regex": [
      "error"
    ],
    "no-dupe-class-members": [
      "error"
    ],
    "no-duplicate-imports": [
      "error"
    ],
    "no-empty": [
      "error",
      {
        "allowEmptyCatch": true
      }
    ],
    "no-empty-pattern": [
      "warn"
    ],
    "no-eq-null": [
      "error"
    ],
    "no-eval": [
      "error"
    ],
    "no-extend-native": [
      "error"
    ],
    "no-extra-bind": [
      "error"
    ],
    "no-extra-label": [
      "warn"
    ],
    "no-extra-parens": [
      "warn"
    ],
    "no-fallthrough": [
      "warn"
    ],
    "no-floating-decimal": [
      "error"
    ],
    "no-implicit-coercion": [
      "warn",
      {
        "boolean": true,
        "number": true,
        "string": true,
        "disallowTemplateShorthand": false
      }
    ],
    "no-implicit-globals": [
      "warn"
    ],
    "no-implied-eval": [
      "error"
    ],
    "no-inline-comments": [
      "off"
    ],
    "no-invalid-this": [
      "error"
    ],
    "no-iterator": [
      "error"
    ],
    "no-label-var": [
      "error"
    ],
    "no-labels": [
      "error",
      {
        "allowLoop": false,
        "allowSwitch": false
      }
    ],
    "no-lone-blocks": [
      "warn"
    ],
    "no-lonely-if": [
      "off"
    ],
    "no-loop-func": [
      "warn"
    ],
    "no-magic-numbers": [
      "off"
    ],
    "no-mixed-spaces-and-tabs": [
      "warn"
    ],
    "no-multiple-empty-lines": [
      "off"
    ],
    "no-multi-assign": [
      "warn"
    ],
    "no-multi-spaces": [
      "warn",
      {
        "ignoreEOLComments": true
      }
    ],
    "no-multi-str": [
      "error"
    ],
    "no-native-reassign": [
      "error"
    ],
    "no-negated-condition": [
      "off"
    ],
    "no-new-func": [
      "error"
    ],
    "no-new-object": [
      "warn"
    ],
    "no-new-symbol": [
      "error"
    ],
    "no-new-wrappers": [
      "error"
    ],
    "no-octal-escape": [
      "error"
    ],
    "no-octal": [
      "error"
    ],
    "no-plusplus": [
      "off"
    ],
    "no-process-env": [
      "error"
    ],
    "no-promise-executor-return": [
      "warn"
    ],
    "no-proto": [
      "error"
    ],
    "no-prototype-builtins": [
      "off"
    ],
    "no-redeclare": [
      "error",
      {
        "builtinGlobals": true
      }
    ],
    "no-restricted-syntax": [
      "warn",
      "WithStatement"
    ],
    "no-return-assign": [
      "error"
    ],
    "no-return-await": [
      "error"
    ],
    "no-script-url": [
      "error"
    ],
    "no-self-assign": [
      "error"
    ],
    "no-self-compare": [
      "error"
    ],
    "no-sequences": [
      "error"
    ],
    "no-shadow": [
      "error",
      {
        "builtinGlobals": true,
        "allow": [
          "close",
          "event",
          "external",
          "innerHeight",
          "length",
          "module",
          "name",
          "open",
          "parent",
          "print",
          "prompt",
          "status",
          "test",
          "toolbar",
          "top",
          "URL"
        ],
        "hoist": "functions"
      }
    ],
    "no-shadow-restricted-names": [
      "error"
    ],
    "no-template-curly-in-string": [
      "warn"
    ],
    "no-ternary": [
      "off"
    ],
    "no-this-before-super": [
      "error"
    ],
    "no-trailing-spaces": [
      "warn"
    ],
    "no-throw-literal": [
      "error"
    ],
    "no-undef": [
      "error"
    ],
    "no-undef-init": [
      "error"
    ],
    "no-underscore-dangle": [
      "off"
    ],
    "no-undefined": [
      "off"
    ],
    "no-unmodified-loop-condition": [
      "warn"
    ],
    "no-unneeded-ternary": [
      "warn"
    ],
    "no-unreachable-loop": [
      "warn"
    ],
    "no-unused-expressions": [
      "warn",
      {
        "allowTernary": true,
        "allowShortCircuit": false,
        "allowTaggedTemplates": false,
        "enforceForJSX": false
      }
    ],
    "no-unused-labels": [
      "warn"
    ],
    "no-unused-private-class-members": [
      "warn"
    ],
    "no-unused-vars": [
      "warn",
      {
        "vars": "all",
        "args": "after-used"
      }
    ],
    "no-use-before-define": [
      "error",
      "nofunc"
    ],
    "no-useless-call": [
      "warn"
    ],
    "no-useless-catch": [
      "warn"
    ],
    "no-useless-computed-key": [
      "warn"
    ],
    "no-useless-concat": [
      "warn"
    ],
    "no-useless-constructor": [
      "error"
    ],
    "no-useless-rename": [
      "warn"
    ],
    "no-useless-return": [
      "warn"
    ],
    "no-var": [
      "error"
    ],
    "no-void": [
      "warn",
      {
        "allowAsStatement": true
      }
    ],
    "no-warning-comments": [
      "off"
    ],
    "no-whitespace-before-property": [
      "warn"
    ],
    "no-with": [
      "error"
    ],
    "object-curly-newline": [
      "off"
    ],
    "object-curly-spacing": [
      "warn",
      "never"
    ],
    "object-shorthand": [
      "off"
    ],
    "one-var-declaration-per-line": [
      "off"
    ],
    "operator-assignment": [
      "off"
    ],
    "operator-linebreak": [
      "warn",
      "after",
      {
        "overrides": {
          "?": "ignore",
          ":": "ignore"
        }
      }
    ],
    "padded-blocks": [
      "off"
    ],
    "padding-line-between-statements": [
      "warn",
      {
        "blankLine": "always",
        "prev": "directive",
        "next": "*"
      },
      {
        "blankLine": "any",
        "prev": "directive",
        "next": "directive"
      }
    ],
    "prefer-arrow-callback": [
      "off"
    ],
    "prefer-const": [
      "warn"
    ],
    "prefer-object-has-own": [
      "off"
    ],
    "prefer-reflect": [
      "off"
    ],
    "prefer-rest-params": [
      "off"
    ],
    "prefer-spread": [
      "off"
    ],
    "prefer-template": [
      "off"
    ],
    "quotes": [
      "warn",
      "single",
      "avoid-escape"
    ],
    "radix": [
      "error"
    ],
    "require-atomic-updates": [
      "warn"
    ],
    "require-yield": [
      "error"
    ],
    "semi": [
      "warn",
      "always"
    ],
    "semi-spacing": [
      "warn",
      {
        "before": false,
        "after": true
      }
    ],
    "semi-style": [
      "error",
      "last"
    ],
    "sort-imports": [
      "off"
    ],
    "sort-vars": [
      "off"
    ],
    "space-before-blocks": [
      "warn"
    ],
    "space-before-function-paren": [
      "warn",
      {
        "anonymous": "always",
        "named": "never"
      }
    ],
    "space-infix-ops": [
      "warn"
    ],
    "space-unary-ops": [
      "warn",
      {
        "words": true,
        "nonwords": false
      }
    ],
    "spaced-comment": [
      "off",
      "always"
    ],
    "strict": [
      "error"
    ],
    "switch-colon-spacing": [
      "error",
      {
        "after": true,
        "before": false
      }
    ],
    "template-curly-spacing": [
      "error"
    ],
    "unicode-bom": [
      "error",
      "never"
    ],
    "vars-on-top": [
      "error"
    ],
    "wrap-iife": [
      "error",
      "outside"
    ],
    "wrap-regex": [
      "off"
    ],
    "yield-star-spacing": [
      "error"
    ],
    "yoda": [
      "error",
      "never",
      {
        "exceptRange": true,
        "onlyEquality": false
      }
    ],
    "for-direction": [
      "error"
    ],
    "getter-return": [
      "error"
    ],
    "no-async-promise-executor": [
      "error"
    ],
    "no-compare-neg-zero": [
      "error"
    ],
    "no-cond-assign": [
      "error"
    ],
    "no-constant-condition": [
      "error"
    ],
    "no-control-regex": [
      "error"
    ],
    "no-debugger": [
      "error"
    ],
    "no-dupe-args": [
      "error"
    ],
    "no-dupe-else-if": [
      "error"
    ],
    "no-dupe-keys": [
      "error"
    ],
    "no-duplicate-case": [
      "error"
    ],
    "no-empty-character-class": [
      "error"
    ],
    "no-ex-assign": [
      "error"
    ],
    "no-extra-boolean-cast": [
      "error"
    ],
    "no-extra-semi": [
      "error"
    ],
    "no-func-assign": [
      "error"
    ],
    "no-global-assign": [
      "error"
    ],
    "no-import-assign": [
      "error"
    ],
    "no-inner-declarations": [
      "error"
    ],
    "no-invalid-regexp": [
      "error"
    ],
    "no-irregular-whitespace": [
      "error"
    ],
    "no-loss-of-precision": [
      "error"
    ],
    "no-misleading-character-class": [
      "error"
    ],
    "no-nonoctal-decimal-escape": [
      "error"
    ],
    "no-obj-calls": [
      "error"
    ],
    "no-regex-spaces": [
      "error"
    ],
    "no-setter-return": [
      "error"
    ],
    "no-sparse-arrays": [
      "error"
    ],
    "no-unexpected-multiline": [
      "error"
    ],
    "no-unreachable": [
      "error"
    ],
    "no-unsafe-finally": [
      "error"
    ],
    "no-unsafe-negation": [
      "error"
    ],
    "no-unsafe-optional-chaining": [
      "error"
    ],
    "no-useless-backreference": [
      "error"
    ],
    "no-useless-escape": [
      "error"
    ],
    "use-isnan": [
      "error"
    ],
    "valid-typeof": [
      "error"
    ]
  },
  "settings": {},
  "ignorePatterns": [
    ".eslintrc.js",
    "configs/eslint-plugin-custom/",
    "dist/",
    "doc/",
    "node_modules/",
    "rollout/",
    "temp/",
    "test/selenium/public/",
    "test/selenium-jest/public/",
    "vendor/"
  ]
}
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
	const item = e.target.value;
}

Expected Result

No warning

Actual Result

The use of the HTMLInputElement instead of the default Element types is reported as warning This is the default value for this type parameter, so it can be omitted.

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 5.12.0
@typescript-eslint/parser 5.12.0
TypeScript 4.5.5
ESLint 8.9.0
node 16.14.0
@doberkofler doberkofler added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 14, 2022
@bradzacher
Copy link
Member

I'm unable to reproduce this against master. playground

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for team members to take a look labels Feb 14, 2022
@doberkofler
Copy link
Contributor Author

Strange. I have the same problem in multiple repositories and just double checked and simply reverting to version 5.11.0 eliminates the false positive.

@doberkofler
Copy link
Contributor Author

I have updated the configuration with the complete configuration from npx eslint --print-config "./**/*.{ts,tsx}"

@Avasam
Copy link

Avasam commented Feb 14, 2022

I can confirm this is happening to me as well after upgrading to:

    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",

Reverting only @typescript-eslint to ~5.11.0 fixes the issue below
image
(The default is Element)

@bradzacher
Copy link
Member

Weirdly it reproduces locally - but not in the playground.

@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working and removed awaiting response Issues waiting for a reply from the OP or another party labels Feb 15, 2022
AnnikaCodes added a commit to smogon/pokemon-showdown that referenced this issue Feb 15, 2022
Per typescript-eslint/typescript-eslint#4554, the rule against unnecessarily specifying the type for a generic is currently producing false positives.

I have disabled it for now, but it should probably be turned back on once the upstream bug is fixed.
@lukaVarga
Copy link

A bunch of false positives for us as well with 5.12.0 (while 5.11.0 is fine).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
4 participants