随笔分类 -  TypeScript

摘要:TypeScript tries to infer as much about your code as it can. But sometimes there really is not enough context for it to infer reliably. If it tried to 阅读全文
posted @ 2017-02-23 04:20 Zhentiw 阅读(281) 评论(0) 推荐(0)
摘要:Function Type: Interface: 阅读全文
posted @ 2017-02-10 03:26 Zhentiw 阅读(147) 评论(0) 推荐(0)
摘要:Example 1: A never stop while loop return a never type. Example 2: Never run If block You can use this to do exhaustive checks in union types. For exa 阅读全文
posted @ 2017-02-01 01:36 Zhentiw 阅读(232) 评论(0) 推荐(0)
摘要:Observable.prototype.debug = function(message: any) { return this.do( (next) => { if(!environment.production) { console.log(message, next); } }, (err) => { ... 阅读全文
posted @ 2017-01-25 17:05 Zhentiw 阅读(342) 评论(0) 推荐(0)
摘要:this is probably the most tricky thing to use in JavaScript and therefore TypeScript. Fortunately there is a TypeScript compiler flag noImplicit this  阅读全文
posted @ 2017-01-21 17:41 Zhentiw 阅读(196) 评论(0) 推荐(0)
摘要:Learn how to write a promise based delay function and then use it in async await to see how much it simplifies code over setTimeout. Lets say you want 阅读全文
posted @ 2017-01-17 14:13 Zhentiw 阅读(195) 评论(0) 推荐(0)
摘要:It can be painful to write the same function repeatedly with different types. Typescript generics allow us to write 1 function and maintain whatever t 阅读全文
posted @ 2016-10-14 19:54 Zhentiw 阅读(183) 评论(0) 推荐(0)
摘要:Sometimes the compiler needs help figuring out a type. In this lesson we learn how to help out the compiler with Typescript type assertion. We have a  阅读全文
posted @ 2016-10-14 19:38 Zhentiw 阅读(425) 评论(0) 推荐(0)
摘要:Typescript classes make inheritance much easier to write and understand. In this lesson we look into how to set up inheritance with Typescript classes 阅读全文
posted @ 2016-10-14 03:06 Zhentiw 阅读(202) 评论(0) 推荐(0)
摘要:Typescript classes make traditional object oriented programming easier to read and write. In this lesson we learn about class syntax, what the constru 阅读全文
posted @ 2016-10-13 21:51 Zhentiw 阅读(280) 评论(0) 推荐(0)
摘要:It’s easy to pass the wrong value to a function. Typescript interfaces are great because they catch errors at compile time or in an IDE. In this lesso 阅读全文
posted @ 2016-10-10 01:52 Zhentiw 阅读(554) 评论(0) 推荐(0)
摘要:In JavaScript, many libraries use string arguments to change behavior. In this lesson we learn how Typescript catches string related errors at compile 阅读全文
posted @ 2016-10-09 03:29 Zhentiw 阅读(183) 评论(0) 推荐(0)
摘要:When to use Interface and when to use Class. Let's see one example: We have an Interface 'Lesson' and a Class 'Lesson'. At this point, I would love to 阅读全文
posted @ 2016-10-07 05:07 Zhentiw 阅读(722) 评论(0) 推荐(0)
摘要:Sometimes we want our function arguments to be able to accept more than 1 type; e.g. a string or an array. This lesson will show us how to assign more 阅读全文
posted @ 2016-10-06 20:31 Zhentiw 阅读(645) 评论(0) 推荐(0)
摘要:It's common in Javascript for functions to accept different argument types and to also return different types. In this lesson we learn how to 'teach' 阅读全文
posted @ 2016-06-17 00:39 Zhentiw 阅读(249) 评论(0) 推荐(0)
摘要:First, what is 'High Order function', basic just a function, inside the function return another fuction. For example: Decorators is a subset of high o 阅读全文
posted @ 2016-06-14 03:10 Zhentiw 阅读(386) 评论(0) 推荐(0)
摘要:TypeScript allows you to generate definition files for your own libraries. This lesson shows you how to organize your project and generate the definit 阅读全文
posted @ 2016-06-14 02:06 Zhentiw 阅读(271) 评论(0) 推荐(0)
摘要:When multiple decorators apply to a single declaration, their evaluation is similar to function composition in mathematics. In this model, when compos 阅读全文
posted @ 2016-06-13 21:24 Zhentiw 阅读(202) 评论(0) 推荐(0)
摘要:TypeScript allows you to emit decorator metadata which enables more powerful features through reflection. This lesson show you how decorators and refl 阅读全文
posted @ 2016-06-11 05:07 Zhentiw 阅读(1061) 评论(0) 推荐(0)
摘要:Decorators are a feature of TypeScript that are becoming more and more common in many major libraries. This lesson walks you through what decorators a 阅读全文
posted @ 2016-06-10 17:39 Zhentiw 阅读(159) 评论(0) 推荐(0)