TypeScript tip: Avoid prefixing interfaces with "I"


TypeScript tip: Avoid prefixing interfaces with "I".

The "I" prefix is a C# convention, but not a TypeScript convention.

In TypeScript, prefixing with "I" isn't necessary, and it makes the code clumsier to read and write.

On rare occasions there can be a naming conflict.

In these rare cases, alias the interface when I import it:

import { User as UserType } from “./user”
Many good comments in this thread, so let me add a simple rule:

If you are using classes in TypeScript, keep the I prefix so you can do this:

class User extends IUser

Otherwise, you probably don't need the "I" prefix.

(I avoid class in TS. I prefer functional TS.)

View original on X