Why no prefix "I" for interfaces?

Topics: General
Oct 29, 2012 at 11:16 AM

The MS type definition files does not use an "I" prefix interface naming convention. Instead they only have upper case first letters. Same thing with most (but not all) existing community added type definition files it seems ( https://github.com/borisyankov/DefinitelyTyped/tree/master/Definitions )

I wonder about the reasoning for this. I think an "I" prefix does make sense, clearly separating interfaces from classes, and making obvious what is only an interface - with no meaning outside of typescript.

Oct 29, 2012 at 5:05 PM

There are a couple reasons, but it largely comes down to a matter of taste.

Most of what is described in .d.ts files are interfaces, meaning that most of the code you write which connects to external libraries will have "I" in them.  This isn't particularly helpful to the developer to know it's an interface, and with so many interface, the code beings to look very "I"-heavy. 

The second is that because TypeScript is structurally typed, interfaces are how you describe the types themselves.  This sets it apart from other common languages with interfaces, and again, leads to having lots of interfaces for certain coding styles.

Ultimately, though, it's up to the user whether or not they use 'I' for their projects.