Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use type instead of interface #151

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichaelDeBoey
Copy link
Member

No description provided.

@MichaelDeBoey MichaelDeBoey requested a review from a team September 30, 2023 15:07
@RunDevelopment
Copy link

May I ask what motivates this change?

@MichaelDeBoey
Copy link
Member Author

@RunDevelopment As I already explained in eslint-community/eslint-utils#60 (comment)

  • Interfaces can't express unions, mapped types, or conditional types. Type aliases can express any type.
  • Interfaces with the same name in the same scope merge their declarations, leading to unexpected bugs.
  • Type aliases have an implicit index signature of Record<PropertyKey, unknown>

@RunDevelopment
Copy link

I see. Thank you for sharing, I didn't know about point 3.

That being said, I don't think using type will be possible here. Type expressions are difficult for TS to make sense of when they contain cycles.

@voxpelli
Copy link
Member

voxpelli commented Oct 6, 2023

Though interfaces can eg. be extended, and that's preferred over using intersections: https://github.com/microsoft/TypeScript/wiki/Performance#preferring-interfaces-over-intersections

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

Successfully merging this pull request may close these issues.

3 participants