typescript-exercises(十四)
人心就是立国的大根本。——孙中山 问题: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194...
typescript-exercises(十三)
人不仅为自己而生,而且也为祖国活着。——柏拉图 题目: 123456// This enables module augmentation mode.import 'date-wizard';declare module 'date-wizard' { // Add your module extensions here.} 报错: 12345index.ts(79,30): error TS2339: Property 'pad' does not exist on type 'typeof import("/node_modules/date-wizard/index.d.ts")'.index.ts(101,67): error TS2339: Property 'hours' does not exist on type 'DateDetails'.test.ts(5,5): error TS2344:...
typescript-exercises(十二)
人民是土壤,它含有要切事物发展所必需的生命汁液;而个人则是这土壤上的花朵与果实。——别林斯基 题目: 123declare module 'stats' { export function getMaxIndex(input: unknown, comparator: unknown): unknown;} 报错: 123456789101112131415index.ts(3,5): error TS2305: Module '"stats"' has no exported member 'getMaxElement'.index.ts(4,5): error TS2724: Module '"stats"' has no exported member 'getMinIndex'. Did you mean 'getMaxIndex'?index.ts(5,5): error TS23...
typescript-exercises(十一)
人只有在人们中间才能认识自己。——歌德 题目: 1234declare module 'str-utils' { // export const ... // export function ...} 报错: 123456index.ts(2,5): error TS2305: Module '"str-utils"' has no exported member 'strReverse'.index.ts(3,5): error TS2305: Module '"str-utils"' has no exported member 'strToLower'.index.ts(4,5): error TS2305: Module '"str-utils"' has no exported member 'strToUpper'.index.ts(...
typescript-exercises(十)
如果你不尊敬你的父母,那你的孩子也将不会尊敬你。——佚名 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146/*Intro: We have asynchronous functions now, advanced technology. This makes us a tech startup officially now. But one of t...
typescript-exercises(九)
如果你要宽容别人的过错,就要把眼光放到自己身上。——佚名 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170/*Intro: PowerUsers idea was bad. Once those users got ...
typescript-exercises(八)
再也无需前思后想,一切岂非已然过往。——《且听风吟》 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293/*Intro: Project grew and we ended up in a situation with some users starting to have more influence. Therefore, we decided to create a new person type called PowerUser which is supposed to combine everything User and Admin have.Exercise: Define type PowerUser which sh...
typescript-exercises(七)
若我会见到你,事隔经年。我如何和你招呼,以眼泪,以沉默。——《春逝》 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125/*Intro: Filtering was completely removed from the project. It turned out that this feature was just not needed for the end-user and we spent a lot of time just because our offi...
typescript-exercises(六)
请热爱劳动,即使不是靠它吃饭,也可以为了身体的缘故而爱它,它可以增进身心健康,免除怠惰之累。——潘恩 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384/*Intro: Filtering requirements have grown. We need to be able to filter any kind of Persons.Exercise: Fix typing for the filterPersons so that it can filter users and return User[] when personType='user' and return Admin[] when personType='admin'...
typescript-exercises(五)
一次冒险,胜过一千个安逸的日子。——保罗·科埃略《韦罗妮卡决定去死》 题目: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108/*Intro: Time to filter the data! In order to be flexible we filter users using a number of criteria and return only those matching all of the criteria. We don't need Admins yet, we only filter Users.Exercise: Without du...
