question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type error in `RuleDocsInfo`

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
Berger92commented, Sep 5, 2022

Hi @B2o5T, no worries. Thanks for taking a look. If you like the proposed solution I’m happy to put the PR together.

1reaction
Berger92commented, Sep 26, 2022

Yeah, good idea Re meta.docs 👍 I’ll take a look a bit later today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type error in `RuleDocsInfo` - PullAnswer
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'],...
Read more >
Releases · B2o5T/graphql-eslint - GitHub
ESLint parser, plugin and set rules for GraphQL (for schema and operations). Easily customizable with custom rules. Integrates with IDEs and ...
Read more >
graphql-eslint - Bountysource
Type error in `RuleDocsInfo ` $ 0 ... Created 2 months ago in dotansimha/graphql-eslint with 3 comments. Issue workflow progress. Progress of the...
Read more >
node.js - Typescript error when adding property to Error object ...
TypeScript does not allow adding unknown properties. There are ways to define objects with arbitrary keys (e.g. Record ).
Read more >
Deciphering TypeScript's React errors | by Fiona Hopkins |
Getting a prop's type wrong, such as passing a string when it expects a number. If we write these bugs, TypeScript will show...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found