littlecodeguy
littlecodeguy

曲中作樂,以曲為生

Typescript小貼士:Type Guard

Array Manipulation 經常用到 `filter()` 但 typescript 唔會幫你 infer 個 output type,所以好多時都要用 `as` 去 override 個 type, 但最好嘅方法係用 type guard function 去比 hint typescript。

Array Manipulation 經常用到 `filter()` 但 typescript 唔會幫你 infer 個 output type,所以好多時都要用 `as` 去 override 個 type, 但最好嘅方法係用 type guard function 去比 hint typescript。

https://littlecodeguy.com/post/2022-08-02-arr-type-guard/…


CC BY-NC-ND 2.0

Like my work?
Don't forget to support or like, so I know you are with me..

Loading...

Want to read more ?

Login with one click and join the most diverse creator community.