获取 storaged u64 上的默认值

Get default value on storaged u64

我想获取存储值,如果不存在,请给我0

const lastDeposit = storage.get<u64>('lastDeposit', u64(0)) || u64(0);

但是编译器抛出

ERROR AS204: Type 'u64' cannot be nullable.

   static get<T>(key: string, defaultValue: T | null = null): T | null {
                                            ~
 in ~lib/near-sdk-core/storage.ts(178,44)

ERROR AS204: Type 'u64' cannot be nullable.

   static get<T>(key: string, defaultValue: T | null = null): T | null {
                                                              ~
 in ~lib/near-sdk-core/storage.ts(178,62)

你必须以 lastDeposit 永远不允许 null

的方式来表达

这是为我编译的,但有错误

const lastDeposit: u64 = storage.getSome<u64>('lastDeposit') || 0;