Skip to content
gqlxj1987's Blog
Go back

Typescript intro

Edit page

interface仅包含数据

class 包含数据和方法

interface有父类的含义?

$ tsc ext5.ts
$ node ext5.js

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

any类型

void

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).

let someValue: any = "this is a string";

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

Edit page
Share this post on:

Previous Post
Serverless inferencing on k8s
Next Post
Linux default 4k page size