Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Nov 14, 2023
1 parent e5a2679 commit 46c4809
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const defaultPattern = new Pattern(() => ({}));

interface Processor {
pattern: Pattern;
process: (file: File) => void;
process: (file?: File) => any;
}

class Box extends EventEmitter {
Expand Down
2 changes: 1 addition & 1 deletion lib/extend/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface StoreFunctionData {
text?: string;
engine?: string;
toString?: any;
onRenderEnd?: any;
onRenderEnd?: (...args: any[]) => any;
}

export interface StoreSyncFunction {
Expand Down
2 changes: 1 addition & 1 deletion lib/hexo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { EventEmitter } from 'events';
import { readFile } from 'hexo-fs';
import Module from 'module';
import { runInThisContext } from 'vm';
const {version} = require('../../package.json');
const { version } = require('../../package.json');
import logger from 'hexo-log';

import {
Expand Down
2 changes: 1 addition & 1 deletion lib/hexo/load_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export = async (ctx: Hexo): Promise<void> => {
const themeDirFromNodeModules = join(ctx.plugin_dir, 'hexo-theme-' + theme) + sep; // base_dir/node_modules/hexo-theme-[config.theme]/

// themeDirFromThemes has higher priority than themeDirFromNodeModules
let ignored = [];
let ignored: string[] = [];
if (await exists(themeDirFromThemes)) {
ctx.theme_dir = themeDirFromThemes;
ignored = ['**/themes/*/node_modules/**', '**/themes/*/.git/**'];
Expand Down
6 changes: 3 additions & 3 deletions lib/hexo/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Render {
const ctx = this.context;
let ext = '';

let promise: Promise<string | Buffer>;
let promise: Promise<string>;

if (!data) return Promise.reject(new TypeError('No input file or string!'));

Expand All @@ -74,10 +74,10 @@ class Render {
} else if (!data.path) {
return Promise.reject(new TypeError('No input file or string!'));
} else {
promise = readFile(data.path);
promise = readFile(data.path) as Promise<string>;
}

return promise.then((text: string) => {
return promise.then(text => {
data.text = text;
ext = data.engine || getExtname(data.path);
if (!ext || !this.isRenderable(ext)) return text;
Expand Down
4 changes: 2 additions & 2 deletions lib/hexo/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Scaffold {
}).asCallback(callback);
}

set(name: string, content: any, callback: NodeJSLikeCallback<void>): Promise<void> {
set(name: string, content: any, callback?: NodeJSLikeCallback<void>): Promise<void> {
const { scaffoldDir } = this;

return this._getScaffold(name).then(item => {
Expand All @@ -72,7 +72,7 @@ class Scaffold {
}).asCallback(callback);
}

remove(name: string, callback: NodeJSLikeCallback<void>): Promise<void> {
remove(name: string, callback?: NodeJSLikeCallback<void>): Promise<void> {
return this._getScaffold(name).then(item => {
if (!item) return;

Expand Down
1 change: 1 addition & 0 deletions lib/plugins/console/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type Hexo from '../../hexo';

interface ConfigArgs {
_: string[]
[key: string]: any
}

function configConsole(this: Hexo, args: ConfigArgs): Promise<void> {
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/console/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { underline, magenta } from 'picocolors';
import type Hexo from '../../hexo';

interface DeployArgs {
_: string[]
_?: string[]
g?: boolean
generate?: boolean
[key: string]: any
}

function deployConsole(this: Hexo, args: DeployArgs) {
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/console/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface GenerateArgs {
watch?: boolean
d?: boolean
deploy?: boolean
[key: string]: any
}

class Generater {
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/console/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Hexo from '../../hexo';

interface MigrateArgs {
_: string[]
[key: string]: any
}

function migrateConsole(this: Hexo, args: MigrateArgs) {
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/console/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface NewArgs {
slug?: string
r?: boolean
replace?: boolean
[key: string]: any
}

function newConsole(this: Hexo, args: NewArgs) {
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/console/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface PublishArgs {
_: string[]
r?: boolean
replace?: boolean
[key: string]: any
}

function publishConsole(this: Hexo, args: PublishArgs) {
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/console/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface RenderArgs {
output?: string
pretty?: boolean
engine?: string
[key: string]: any
}

function renderConsole(this: Hexo, args: RenderArgs) {
Expand Down

0 comments on commit 46c4809

Please sign in to comment.