Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

no-unnecessary-generics reporting in a less useful place than it could?

Open
#734 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
eslint, typescript
Domain
tooling

Research direction

Read packages/eslint-plugin/src/rules/no-unnecessary-generics.ts around line 57, then reproduce the TypeScript example from the issue to observe the current diagnostic location. Done means the rule reports the first mention of TElement rather than the JQuery return type, with behavior covered by the relevant rule tests if present.

Written by the indexing model from the issue text.

Description

Hi all!

I've been looking into this Definitely Typed pull request and picking through the issues with @JoshuaKGoldberg. We encountered an interesting case with the no-unnecessary-generics rule which we think could be better. Consider:

    <TElement extends HTMLElement = HTMLElement>(
      html: JQuery.htmlString,
      ownerDocument_attributes?: Document | JQuery.PlainObject,
      // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
    ): JQuery<TElement>;

You'll note that we have an eslint-disable-next-line just before the last line; the ReturnType of the method. Without this in place the red squigglies would be under:

JQuery<TElement>
       ~~~~~~~~

This isn't the useful place to have this report. Perhaps the better place would be the first mention of TElement, like so:

    <TElement extends HTMLElement = HTMLElement>(
     ~~~~~~~~

Looking at https://github.com/microsoft/DefinitelyTyped-tools/blob/822dadbed4d2946f399400fd512599d0a2505d51/packages/eslint-plugin/src/rules/no-unnecessary-generics.ts#L57 it seems this is intentional.

Is this good? What do you think?

Dominant language
TypeScript
Stars
422
Forks
238
Avg merge
1d 4h
Merged PRs (30d)
8

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/DefinitelyTyped-tools

All issues in microsoft/DefinitelyTyped-tools

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.