
typescript
小绿龙
node.js/php/go
展开
-
typescript中的队列
队列类 class Queue { private data = []; push = item => this.data.push(item); pop = () => this.data.shift(); } typescript版本的队列 /** * pop的返回值当data为空时返回undefined * 使用了泛型约束 */ class QueueT<T>...原创 2019-04-22 12:11:19 · 3318 阅读 · 0 评论 -
typescript中的类型别名
关键词type // 类型别名用法 自定义自己类型 type myType = { name: string, age: number, }原创 2019-04-19 14:36:41 · 2040 阅读 · 0 评论 -
Type 'CrazyClass' provides no match for the signature 'new (): { hello: number; }'
今天看TypeScript Deep Dive的时候有个例子 interface Crazy { new(): { hello: number; }; } class CrazyClass implements Crazy { constructor() { return { hello: 123 }; } } // Becaus...原创 2019-09-10 18:12:55 · 1623 阅读 · 0 评论