Skip to content

Type error in RuleDocsInfo #1146

@Berger92

Description

@Berger92

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

Please make sure the graphql-eslint version under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

Hi 👋
This is just a small thing that I discovered when I wanted to add urls to our rules and TS didn't like it with the strict flag on, because url wasn't part of RuleDocsInfo.

I took a closer look and discovered that the problem is caused by docs being optional, and therefore the type returned by Omit<Rule.RuleMetaData['docs'], 'category'> is {}.

export type RuleDocsInfo<T> = {
  docs: Omit<Rule.RuleMetaData['docs'], 'category'> & {   <<<<<
    category: CategoryType | CategoryType[];
    requiresSchema?: true;
    requiresSiblings?: true;
    ...
  };
};

To Reproduce

Screenshot 2022-08-25 at 10 30 03

Expected behavior

I think you wanted to keep all the properties from docs except for category, so that should be happening.

Proposed solution

Adding Required solves it.

Screenshot 2022-08-25 at 10 39 43

Environment:

  • OS: MacOS Monterey
  • @graphql-eslint/eslint-plugin: 3.10.7
  • Node.js: 16

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementNew feature or requeststage/6-releasedThe issue has been solved on a released version of the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions