Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name convention for interfaces in Angular 2? [duplicate]

Doesn't seem to be an explicit place with this information:

I have always named interface files as IMyInterfaceName.extensionand the interface as IMyInterface.

Is that the way to go with Angular 2 and Typescript?

Thanks :)

like image 983
Jose A Avatar asked Mar 19 '16 12:03

Jose A


People also ask

What is the correct naming convention that is used in angular components?

Do use consistent names for all assets named after what they represent. Do use upper camel case for class names. Do match the name of the symbol to the name of the file. Do append the symbol name with the conventional suffix (such as Component , Directive , Module , Pipe , or Service ) for a thing of that type.

WHAT IS interfaces in angular?

An interface is a way to define a contract on a function with respect to the arguments and their type. Along with functions, an interface can also be used with a Class as well to define custom types. An interface is an abstract type, it does not contain any code as a class does.

Should TypeScript interfaces be capitalized?

To solve this, TypeScript introduces the concept of interfaces. By convention, the interface names are in the camel case. They use a single capitalized letter to separate words in there names.


1 Answers

According to NAMING.md.

In general Angular2 should follow TypeScript naming conventions. See: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines

This is what it says about interfaces:

Interfaces:

Follow the same rules as Classes
Should not have I or Interface in the name or any other way of identifying it as an interface.

like image 171
Eric Martinez Avatar answered Oct 23 '22 06:10

Eric Martinez