随笔分类 - 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
阅读全文
摘要:Function Type: Interface:
阅读全文
摘要: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
阅读全文
摘要:Observable.prototype.debug = function(message: any) { return this.do( (next) => { if(!environment.production) { console.log(message, next); } }, (err) => { ...
阅读全文
摘要:this is probably the most tricky thing to use in JavaScript and therefore TypeScript. Fortunately there is a TypeScript compiler flag noImplicit this
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Typescript classes make inheritance much easier to write and understand. In this lesson we look into how to set up inheritance with Typescript classes
阅读全文
摘要:Typescript classes make traditional object oriented programming easier to read and write. In this lesson we learn about class syntax, what the constru
阅读全文
摘要: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
阅读全文
摘要:In JavaScript, many libraries use string arguments to change behavior. In this lesson we learn how Typescript catches string related errors at compile
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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'
阅读全文
摘要: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
阅读全文
摘要:TypeScript allows you to generate definition files for your own libraries. This lesson shows you how to organize your project and generate the definit
阅读全文
摘要:When multiple decorators apply to a single declaration, their evaluation is similar to function composition in mathematics. In this model, when compos
阅读全文
摘要:TypeScript allows you to emit decorator metadata which enables more powerful features through reflection. This lesson show you how decorators and refl
阅读全文
摘要: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
阅读全文

浙公网安备 33010602011771号