diff --git a/shared/api/buildStorage.ts b/shared/api/buildStorage.ts index 4fdd3739..5ff39756 100644 --- a/shared/api/buildStorage.ts +++ b/shared/api/buildStorage.ts @@ -78,7 +78,7 @@ export function buildStorage(backend: any) { } return res; }, - remove: async (key) => { + remove: async (key: string) => { await storage.remove({ key }); }, /** diff --git a/shared/components/FastForm/index.tsx b/shared/components/FastForm/index.tsx index 008cd847..312216a5 100644 --- a/shared/components/FastForm/index.tsx +++ b/shared/components/FastForm/index.tsx @@ -74,7 +74,7 @@ export const FastForm: React.FC = React.memo((props) => { {...fieldMeta} value={value} error={error} - onChange={(val) => setFieldValue(fieldName, val)} + onChange={(val: any) => setFieldValue(fieldName, val)} /> ); } diff --git a/shared/hooks/useAsync.ts b/shared/hooks/useAsync.ts index 2944c530..d7cca6ac 100644 --- a/shared/hooks/useAsync.ts +++ b/shared/hooks/useAsync.ts @@ -1,5 +1,5 @@ import { DependencyList, useEffect } from 'react'; -import { FunctionReturningPromise } from '../types'; +import type { FunctionReturningPromise } from '../types'; import { useAsyncFn } from './useAsyncFn'; // Reference: https://github.com/streamich/react-use/blob/master/src/useAsync.ts diff --git a/shared/types/index.d.ts b/shared/types/index.d.ts new file mode 100644 index 00000000..96d526e2 --- /dev/null +++ b/shared/types/index.d.ts @@ -0,0 +1 @@ +declare module 'str2int'; diff --git a/shared/utils/__tests__/is-promise.spec.ts b/shared/utils/__tests__/is-promise.spec.ts new file mode 100644 index 00000000..700b60f4 --- /dev/null +++ b/shared/utils/__tests__/is-promise.spec.ts @@ -0,0 +1,16 @@ +import { isPromise } from '../is-promise'; + +describe('isPromise', () => { + test.each([ + [Promise.resolve(), true], + ['str', false], + [123, false], + [[], false], + [{}, false], + [Symbol('sym'), false], + [undefined, false], + [null, false], + ])('%s => %s', (input, should) => { + expect(isPromise(input)).toBe(should); + }); +}); diff --git a/shared/utils/date-helper.ts b/shared/utils/date-helper.ts index 66a45992..bca659df 100644 --- a/shared/utils/date-helper.ts +++ b/shared/utils/date-helper.ts @@ -2,6 +2,10 @@ import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; // 导入插件 import 'dayjs/locale/zh-cn'; // 导入本地化语言 +/** + * Reference: https://day.js.org/ + */ + dayjs.extend(relativeTime); dayjs.locale('zh-cn');