Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
Before You File a Documentation Request Please Confirm You Have Done The Following...
- I have looked for existingopen or closed documentation requests that match my proposal.
- I haveread the FAQ and my problem is not listed.
Suggested Changes
@typescript-eslint/consistent-type-definitions
enforces type definitions to consistently use eitherinterface
ortype
. 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 prefersinterface
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
💖