Skip to content

feat: prefer type definitions - #22

Closed
jobveldhuis wants to merge 1 commit into
mainfrom
feat/prefer-type-definitions
Closed

jobveldhuis wants to merge 1 commit into
mainfrom
feat/prefer-type-definitions

Conversation

@jobveldhuis

@jobveldhuis jobveldhuis commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Ensures that our linting config is actually up-to-date with the idea of types instead of interfaces.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 16:46
@changeset-bot

changeset-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e9ecf0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@incentro-ic/config-eslint Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new rule conflicts with the existing TypeDoc interface policy and documentation.

2 open findings
What changed in this PR

Enforces type aliases over interfaces across the shared ESLint configuration and documents limited exceptions.

Changes:

  • Enables consistent-type-definitions.
  • Expands type-definition guidance and exceptions.
  • Adds a major-version changeset.
File Description
STYLE-GUIDE.md Documents preferred type definitions.
packages/​eslint/​src/​partials/​typescript.ts Enforces type aliases.
.changeset/​prefer-type-definitions.md Records the breaking change.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +69 to +71
// `Record<string, unknown>`. Module augmentation and large `extends`
// hierarchies are valid reasons to disable this rule for one line.
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
Comment thread STYLE-GUIDE.md
There are two exceptions where an interface is the better choice:

- **Module augmentation.** Extending a type declared by a library (like `Window`, or React Router's `Register`) relies on declaration merging, which only interfaces support.
- **Large hierarchies of object types.** When an object type is built by extending several others, prefer `interface … extends` over intersections (`&`). `extends` reports conflicting properties as an error, while an intersection silently turns them into `never`. Typescript also caches `extends` relationships, which keeps type checking fast in large codebases.
@LuudJanssen

Copy link
Copy Markdown
Member

This comment from Copilot is very valid. I chose not to add this rule earlier because there's valid exceptions for this rule, and adding an exception to every public interface because you use Typedoc to generate documentation is also not the solution IMO.

I think this warrants a discussion; do we need to update / change the rule? The arguments mentioned are valid, but do they warrant the downsides? We could probably also prevent automatic merging of interfaces using a different ESLint rule, and the "Large hierarchies of object types." exception happens in enough code bases that requiring exceptions becomes awkward IMO.

We should either:

  • Enforce the rule in reviews and without rules.
  • Change the rule to reflect what works in practice.

@LuudJanssen
LuudJanssen self-requested a review October 15, 2026 08:21

@LuudJanssen LuudJanssen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment.

@jobveldhuis

Copy link
Copy Markdown
Member Author

This comment from Copilot is very valid. I chose not to add this rule earlier because there's valid exceptions for this rule, and adding an exception to every public interface because you use Typedoc to generate documentation is also not the solution IMO.

I think this warrants a discussion; do we need to update / change the rule? The arguments mentioned are valid, but do they warrant the downsides? We could probably also prevent automatic merging of interfaces using a different ESLint rule, and the "Large hierarchies of object types." exception happens in enough code bases that requiring exceptions becomes awkward IMO.

We should either:

  • Enforce the rule in reviews and without rules.
  • Change the rule to reflect what works in practice.

I'm fine not adding the rule and leaving it to reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants