DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

Typescript intro

interface仅包含数据

class 包含数据和方法

interface有父类的含义?

1
2
$ tsc ext5.ts
$ node ext5.js

通过编译,进一步降低js的门槛,同时,也提前避免了解释型语言错误

any类型

void

1
2
let unusable: void = undefined;
unusable = null; // OK if `--strictNullChecks` is not given

never类型

The never type represents the type of values that never occur. The never type is a subtype of, and assignable to, every type; however, no type is a subtype of, or assignable to, never (except never itself).

1
2
3
4
let someValue: any = "this is a string";

let strLength: number = (<string>someValue).length;
let strLength: number = (someValue as string).length;