Top community members
All Wiki Articles Create Wiki Article

In the past we had a dream,
to have place where we could share IT knowledge,
to ask questions without fear that someone will judge us.

Now we are a group of people who make this dream come true. ❤ 💻

If you think sharing knowledge and helping other is valuable.

join our community - Click here

TypeScript - interface naming convention

0 contributions
13 points

In TypeScript interface naming convention contains following rules:

  1. Use PascalCase for interface names.
  2. Use pascalCase for interface members.
  3. Do not use "I" as a prefix for interface names.
  4. Use whole words in names when possible.

Interface naming convention example

interface Square {
    readonly name: string;

    computePerimeter(aSize : number, bSize : number) : number;
    computeArea(aSize: number, bSize: number): number;

    toString(): string;
}

class LocalSquare implements Square {

    get name() : string {
        return 'Square';
    }
    
    public computePerimeter(aSize : number, bSize : number) : number {
        return 2 * aSize + 2 * bSize;
    }

    public computeArea(aSize: number, bSize: number): number {
        return aSize * bSize;
    }

    public toString(): string {
        return '[ ' + this.name + ' object ]';
    }
}

Run it online here.

References

  1. TypeScript Handbook Interface - Microsoft Github Docs
0 contributions

Suggested wiki articles:

Suggested findings

Let's do the work and have some fun
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way. ❤ 💻 🙂
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    we will help you. 👍 ✔ 🦄
Read more