diff --git a/lib/plugins/generator/asset.ts b/lib/plugins/generator/asset.ts index 336c4e2612..70fde55d8c 100644 --- a/lib/plugins/generator/asset.ts +++ b/lib/plugins/generator/asset.ts @@ -3,9 +3,9 @@ import { exists, createReadStream } from 'hexo-fs'; import Promise from 'bluebird'; import { extname } from 'path'; import { magenta } from 'picocolors'; -import type warehouse from 'warehouse'; import type Hexo from '../../hexo'; -import type { AssetGenerator } from '../../types'; +import type { AssetGenerator, AssetSchema } from '../../types'; +import type Document from 'warehouse/dist/document'; interface Data { modified: boolean; @@ -13,21 +13,15 @@ interface Data { } const process = (name: string, ctx: Hexo) => { - // @ts-expect-error - return Promise.filter(ctx.model(name).toArray(), (asset: warehouse['Schema']) => exists(asset.source).tap(exist => { - // @ts-expect-error + return Promise.filter(ctx.model(name).toArray(), (asset: Document) => exists(asset.source).tap(exist => { if (!exist) return asset.remove(); - })).map((asset: warehouse['Schema']) => { - // @ts-expect-error + })).map((asset: Document) => { const { source } = asset; - // @ts-expect-error let { path } = asset; const data: Data = { - // @ts-expect-error modified: asset.modified }; - // @ts-expect-error if (asset.renderable && ctx.render.isRenderable(path)) { // Replace extension name if the asset is renderable const filename = path.substring(0, path.length - extname(path).length); diff --git a/lib/types.ts b/lib/types.ts index 2e8f1a052a..162585c8b0 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -131,6 +131,15 @@ export interface TagSchema { _id?: string | number; name?: string; } + +export interface AssetSchema { + _id?: string; + path: string; + modified: boolean; + renderable: boolean; + source: string; +} + export interface LocalsType { page: PostSchema | PageSchema; path: string;