設置泛型將參數配置為 null 時拋出了如下異常:
Type 'null' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'null'. <ArkTSCheck>
解決辦法
在 null 后面添加 ! 即可,以表示該值不會為 null
data: T = null!
以上便是此次分享的全部內容,希望能對大家有所幫助!