LoginSignup
1
0

More than 5 years have passed since last update.

私的TypeScriptコーディング規約

Posted at

随時更新中。

命名

Variable

  • camelCaseを用いる。

bad

var Num = 10;

good

var num = 10;

Function

  • camelCaseを用いる。

bad

GetId(): number{ }

good

getId(): number { }

Class

  • Class名はPascalCaseを用いる。
  • memberはcamelCaseを用いる。
  • functionはcamelCaseを用いる。

bad

class user {
    Id: number;
    GetId(): number {
        return this.Id;
    }
}

good

class User {
    id: number;
    getId(): number {
        return this.Id;
    }
}

Interface

  • Interface名はPascalCaseを用いる。
  • functionはcamelCaseを用いる。

bad

interface IUser {
    GetId(): number;
}

good

interface User {
    getId(): number;
}

Namespace

  • Namespace名はPascalCaseを用いる。

bad

namespace app {
}

good

namespace App {
}

Array

  • []の代わりにArrayを用いる。

bad

private Users: User[];

good

private Users: Array<User>;
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0