我想获取存储值,如果不存在,请给我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)发布于 2021-10-12 12:12:06
您必须以一种永远不允许lastDeposit为null的方式来表述这一点
这是为我编译的,但有错误
const lastDeposit: u64 = storage.getSome<u64>('lastDeposit') || 0;https://stackoverflow.com/questions/69540021
复制相似问题