-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
documentationDocumentation ("docs") that needs adding/updatingDocumentation ("docs") that needs adding/updatinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.team assignedA member of the typescript-eslint team should work on this.A member of the typescript-eslint team should work on this.
Description
Before You File a Documentation Request Please Confirm You Have Done The Following...
- I have looked for existing open or closed documentation requests that match my proposal.
- I have read the FAQ and my problem is not listed.
Suggested Changes
@typescript-eslint/consistent-type-definitions
enforces type definitions to consistently use either interface
or type
. But the page doesn't link to a real explanation of what the differences are or how you might choose one vs. the other as your default. It doesn't even explain why the rule prefers interface
as a default.
Proposal: let's add in:
- An explanation of why the rule has
'interface'
as its default - Links to resources explaining the differences between the two, including any official TypeScript docs & recommendations
Affected URL(s)
https://typescript-eslint.io/rules/consistent-type-definitions
Additional Info
There's no one link I can find online that's exactly what I'm hoping for...
- https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces is a high-level guide that links to later chapters. It's not a comprehensive resource on its own, but IMO would be good to link to additionally.
- https://www.totaltypescript.com/type-vs-interface-which-should-you-use is one very good deep dive, but it starts off with a different opinion than the rule's default (😂). I think we'll want to stay away from putting forward opinions.
- https://blog.logrocket.com/types-vs-interfaces-typescript: goes a bit into errata (
Array
) and has a good bit more introductory content than I think we need - https://stackoverflow.com/questions/37233735/interfaces-vs-types-in-typescript is a classic StackOverflow answer
💖
Metadata
Metadata
Assignees
Labels
documentationDocumentation ("docs") that needs adding/updatingDocumentation ("docs") that needs adding/updatinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.team assignedA member of the typescript-eslint team should work on this.A member of the typescript-eslint team should work on this.