Skip to content

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

@johnnyreilly

Description

@johnnyreilly

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

node: parserServices.tsNodeToESTreeNodeMap.get(res.soleUse),
it seems this is intentional.

Is this good? What do you think?

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