type inputJSON = { inputText: string, errCode: number } type JsonParamOptions = { input: inputJSON; success: (res: string) => void; fail: (res: string) => void; complete: (res: string) => void; }; /** * 导出一个带callback的同步方法 * @param opts */ export function callWithoutParam(success: () => void) { success(); return { name: "doSthWithCallback" }; } export function callWithStringParam(input: string, success: (res: string) => void) { success(input); return { name: "doSthWithCallback" }; } export function callWithJSONParam(opts: JsonParamOptions) { opts.input.errCode = 10; opts.success(opts.input); return { name: "doSthWithCallback" }; }