Languages
[Edit]
EN

TypeScript - class naming convention

24 points
Created by:
Vanessa-Drake
388

This article explains the rules for class naming convention used in TypeScript.

The class naming convention defines the following rules:

  1. Use PascalCase for class names.
  2. Use camelCase for class members.
  3. Use whole words in names when possible.

Class naming convention example:

class 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 ]`;
    }
}

See also

  1. Programming - PascalCase definition with example

  2. Programming - camelCase definition with example

References

  1. TypeScript Handbook Class - Microsoft Github Docs
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

â€ïžđŸ’» 🙂

Join