TypeScript

開始用typescript做開發了((目前還是先練習當中

使用情況還算OK,不過對於裝飾器(decorator)的東西,我不是很熟悉可能還要再多練習

Definition files也是還沒有開始動手寫過

目前大概都是非常前面的那種HelloWorld等級的東西

宣告部分來說大概類似底下的

let a:number = 1;
let b:string = "helloworld";

function部份為了回傳值,也是更進化了

function returnNumber (i:number):number{
    return i;
}

function returnString(str:string):string {
    return str;
}


也添加了class的應用,我記得ES6才會有支援


class test{
    private m_a:string;
    b:number;
      
    constructor(q:string){
        this.m_a = "Hello" + q;
        this.b = 50;
    }
      
    returnA():string{
         return this.m_a + this.b;
    }
}

let a = new test("world");

console.log(a.returnA());

也添加了很多新概念進去,比原本的JS應該是可以讓其結構更清楚了一些

要不然全程用function+closure做類的處理...做的時候我會真的會回頭看不懂我寫啥鬼...

Reference :

https://blogs.msdn.microsoft.com/ericsk/2012/10/01/typescript/

https://www.gitbook.com/book/zhongsp/typescript-handbook/details


留言

這個網誌中的熱門文章

ts-node 應用

ubuntu 日常(X)紀錄

Angular 2 with Third Party files