Thursday 22 October 2020

Typescript IInterface

If you come from c# or Java you are most likely use to a certain naming convention and that is putting a capital I in front of your interface definitions. However now that you are working on a front end project, and using typescript you most likely have come across the following error 

eslint Interface name must not be prefixed with "I"

now this is a bit of a pain in the ass, the easiest thing to do would be to change your ways and not put the I there maybe name your interfaces something like "personInterface" but no, you are one stubborn fuck.

well I have good news for you the eslint rule is basically a convention, most likely implemented to piss off backend developers I assume this because i can not think of any other reason it exists. Thankfully the rule is very simple to deactivate, somewhere in your project, most like at the root there is a eslintrc.js file, open it and add the following 

'@typescript-eslint/interface-name-prefix': 'off'

With that slight modification you can feel free to use I as prefix for your interfaces to your hearts content.