TypeScript 學習筆記1

2021-07-10 02:59:36 字數 1018 閱讀 8640

inte***ces

typescript 的 type-checking 專注於值的「shape」

inte***ces的作用在於命名值使其便於檢測,同時作為軟體與軟體、軟體內部交流的工具。

用於檢測,編譯成js的話沒有相應的語句

ts:

inte***ce squareconfig

function creatsqure(config:squareconfig);

}

js:function creatsqure(config)

;}

function type

inte***ce functionexm

var myfunctionexm:functionexm;

//...

array type

inte***ce dictionary
class type

inte***ce clockinte***ce 

class clock implements clockinte***ce

constructor(h: number, m: number)

}

describe the public side of the class

extend

inte***ce shape 

inte***ce penstroke

inte***ce square extends shape, penstroke

hybird

inte***ce counter 

var c: counter;

c(10);

c.reset();

c.interval = 5.0;

Typescript學習筆記

物件導向特性 類類的宣告 用class關鍵字 加類名 class person 類宣告完之後就可以被例項化了,類相當於乙個模子.name string eat var p1 new person p1.name batman p1.eat var p2 new person p2.name supe...

typescript學習筆記

1,ts是js的超集,ts是強型別語言。ts比js入門更難。ts的物件導向寫法比js更優雅。ts更適合團隊協作。2,宣告變數篇。3,宣告函式篇。4,物件導向篇。4.1,子類繼承父類 extends 繼承多個介面 implements。4.2,this表示當前物件,super表示父類物件。子類不寫co...

Typescript 入門學習1

最近新學typescript遇到的問題 入口 index.ts import from type import xhr from xhr.js function allpass config allpassconfig let conf allpass conf export default all...