Cache
类型Cache<V = any>
的定义是定义对象还是函数?
这里是通用V
,为什么要指定any
?等号是什么意思?
export interface Cache<V = any> {
value?: V;
timeoutId?: ReturnType<typeof setTimeout>;
time?: number;
alive?: number;
}
Cache
类型Cache<V = any>
的定义是定义对象还是函数?
这里是通用V
,为什么要指定any
?等号是什么意思?
export interface Cache<V = any> {
value?: V;
timeoutId?: ReturnType<typeof setTimeout>;
time?: number;
alive?: number;
}
只是不要写声明.
// app.tsx
const LANG = 'zh-CN'; // This is a top-level scope variable, available globally
// any.d.tsx
declare const LANG: string;
// other.tsx
const currentLang = userLang || LANG; // don't need import LANG from app.tsx了