Type error in `RuleDocsInfo`
See original GitHub issueIssue 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
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.
Environment:
- OS: MacOS Monterey
@graphql-eslint/eslint-plugin
: 3.10.7- Node.js: 16
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:13 (13 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @B2o5T, no worries. Thanks for taking a look. If you like the proposed solution I’m happy to put the PR together.
Yeah, good idea Re
meta.docs
👍 I’ll take a look a bit later today.