correct-apricot
correct-apricotā€¢2y ago

Do resource interfaces have to be interfaces?

Hi! I've followed the documentation while creating a Refine app and when I sent it for review one of reviewers(my coworker) told that the interfaces(the ones that represent resources) are not actually interfaces, because they are not used in our app to implement any classes. This means we can actually change them to be types and not interfaces. So the question is: why does the documentation has them as interfaces? Is it a requirement?
4 Replies
like-gold
like-goldā€¢2y ago
Type and interface have technically different but not so much. TypeScript not strict as other oop languages. Most of time you don't encounter a problem with type or interface. Besides technical aspect, Developers have opinions, conventions and preferences. You can use type if you want. This is not a requirement. if it's, TypeScript will throw errors anyway.
correct-apricot
correct-apricotā€¢2y ago
Sure, it doesn't matter much technically, I was talking more about the semantics and conventions. So, in the documentation it is written as interface just because of preference?
like-gold
like-goldā€¢2y ago
Our core lead members can explain this in more detail šŸ™ when they available I'm pretty sure they will happy the answer logo talk with core team, it just a preference
correct-apricot
correct-apricotā€¢2y ago
Got it, thanks a lot, @alicanerdurmaz !