Skip to content

Code Format

徐宇楠 edited this page Jun 6, 2017 · 9 revisions

code format

//DO NOT USE SHORTCUTS
//such as: instance -> inst
class A {
    private _fieldA; //private field should start with _
    public static readonly STATIC_FIELD_AAA = 1 //static fields all uppercase
    public fieldB; //camel case
    //put fields before methods
    public sayHello() {   //same as public fields
        //It is better to put a pair of "{}" after for/if/when... even if there is only one line.   
        if (this._fieldA) {
             
        }
    }
}

typings

  • put all custom typings(anything like declare something) into typings directory
  • for the typings for global, put it in to lib.d.ts
  • modules' typing, create a file named {MODULE_NAME}.d.ts
  • other typings(for global usage, and just for declaration) create a file named {NAME}.d.ts and declare a namespace like Seityan.{NAME}

test

put test files into test directory

Clone this wiki locally