Archive of stories published by JimYTC Lab

Typescript Array.map 後的型別推論技巧 — Type Predicates

Originally post here => https://jimytc.com/posts/2021/03/27/qnote_on_using_type_predicates/

在集合或陣列類型的資料處理中,偶爾會遇到需要使用 Array.map 把所需要的資料從物件中轉化成另一個陣列物件。 例如

class Foo {
bar?: number

These were the top 10 stories published by JimYTC Lab; you can also dive into yearly archives: 2018, 2019, 2020, and 2021.