随笔分类 - TypeScript
摘要:Generic Fucntion: For example we have a set of data and an function: When we check the 'clones' type, you can see it is 'any[]'. To add more type info
阅读全文
摘要:In the constructor, we want to set the prop to readonly, you need to do like this:
阅读全文
摘要:To fix Promise is not recolized in TypeScript, we can choose to use a lib: we can also use built-in libs: Inside "es6" have Promise already, so that w
阅读全文
摘要:To using decorate, we can modifiy tsconfig.json: So for example we want to build a '@LogMethod' decorator, which arroding to the system logging level
阅读全文
摘要:If you try to use CSS Modules in TypeScript the same way you would use them in JavaScript, with webpack’s css-loader, you’ll see an error: ”TS2307: Ca
阅读全文
摘要:The idea is change from: to: To do that, we need to modify tsconfig.json file:
阅读全文
摘要:The for-await-of syntax is similar to the for-of iteration. The key difference is that it automatically awaits any promises generated by the iterator.
阅读全文
摘要: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
阅读全文
摘要:For example we have an object: We shallow copy it: Verify that shallowCopy is not todo: Change text prop of shallowCopy to somethingelse: But if we wa
阅读全文
摘要:TypeScript’s discriminated union types (aka tagged union types) allow you to model a finite set of alternative object shapes in the type system. The c
阅读全文
摘要:TypeScript 2.0 introduced the readonly modifier which can be added to a property or index signature declaration. It helps prevent against unintended p
阅读全文
摘要:This lesson introduces the --strictNullChecks compiler option and explains how non-nullable types differ from nullable types. It also illustrates how
阅读全文
摘要:Shuffling is a common process used with randomizing the order for a deck of cards. The key property for a perfect shuffle is that each item should hav
阅读全文
摘要:A common interview question is to write a
function
that
converts a string
into
an
integer e.g. "123" => 123. This function is commonly called atoi bec
阅读全文
摘要:In a doubly linked list each node in the list stores the contents of the node and a pointer or reference to the next and the previous nodes in the lis
阅读全文
摘要:In a singly linked list each node in the list stores the contents of the node and a reference (or pointer in some languages) to the next node in the l
阅读全文
摘要:Typescript 2.5 adds JSDoc type assertion support for javascript file via ts-check service. First of all, you should make sure you have typescript@2.5
阅读全文
摘要:From TypeScript@2.5, you can omit catch error block. Before: Now: It is just a syntax sugar, if you are not trying to do error handling
阅读全文
摘要:For example, inside you component you want to import a file from two up directory: This becomes a little bit problematic because the component can be
阅读全文
摘要:We can use 'type' keyword to define a function type. 'digitValidators', is a mapping object, return a function which type is DigitValidator.
阅读全文

浙公网安备 33010602011771号