我正在使用 react native async storage 它运行良好,但在某些情况下,我必须为数据设置到期日期并刷新我检查过的存储
AsyncStorage 文档,但没有设置在特定时间后过期的选项。
唯一可用的选项是:-
AsyncStorage.removeItem
Run Code Online (Sandbox Code Playgroud) 假设我想扩展String.prototype,所以我在ext/string.ts中有这个例子:
interface String {
contains(sub: string): boolean;
}
String.prototype.contains = function (sub:string):boolean {
if (sub === "") {
return false;
}
return (this.indexOf(sub) !== -1);
};
Run Code Online (Sandbox Code Playgroud)
当我这样做import * as string from 'ext/string.ts'失败时出现此错误:
错误TS2306:文件'\ text/string.ts'不是模块
这是假设的行为,我没有写出口.但是我怎么告诉Typescript我想扩展String.prototype呢?
asyncstorage ×1
javascript ×1
node.js ×1
postgresql ×1
react-native ×1
sails.js ×1
typescript ×1