随笔分类 -  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 阅读全文
posted @ 2018-02-12 02:34 Zhentiw 阅读(262) 评论(0) 推荐(0)
摘要:In the constructor, we want to set the prop to readonly, you need to do like this: 阅读全文
posted @ 2018-02-05 19:37 Zhentiw 阅读(477) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-02-03 04:32 Zhentiw 阅读(152) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-02-02 04:08 Zhentiw 阅读(171) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-01-26 20:13 Zhentiw 阅读(495) 评论(0) 推荐(0)
摘要:The idea is change from: to: To do that, we need to modify tsconfig.json file: 阅读全文
posted @ 2018-01-26 03:22 Zhentiw 阅读(217) 评论(0) 推荐(0)
摘要: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. 阅读全文
posted @ 2018-01-24 20:55 Zhentiw 阅读(386) 评论(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 @ 2018-01-24 20:09 Zhentiw 阅读(174) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-13 17:59 Zhentiw 阅读(274) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-13 17:48 Zhentiw 阅读(385) 评论(0) 推荐(0)
摘要:TypeScript 2.0 introduced the readonly modifier which can be added to a property or index signature declaration. It helps prevent against unintended p 阅读全文
posted @ 2017-11-09 21:06 Zhentiw 阅读(283) 评论(0) 推荐(0)
摘要:This lesson introduces the --strictNullChecks compiler option and explains how non-nullable types differ from nullable types. It also illustrates how 阅读全文
posted @ 2017-11-08 17:45 Zhentiw 阅读(339) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-10-03 18:39 Zhentiw 阅读(517) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-10-03 16:17 Zhentiw 阅读(294) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-10-03 01:56 Zhentiw 阅读(934) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-10-02 19:01 Zhentiw 阅读(434) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-09-09 20:55 Zhentiw 阅读(343) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-09-06 22:34 Zhentiw 阅读(214) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-07-28 02:30 Zhentiw 阅读(228) 评论(0) 推荐(0)
摘要:We can use 'type' keyword to define a function type. 'digitValidators', is a mapping object, return a function which type is DigitValidator. 阅读全文
posted @ 2017-07-24 02:41 Zhentiw 阅读(469) 评论(0) 推荐(0)