审查生成的支付声明

来自声明文件
TypeScript 6 高级 6分钟 找出4处问题

审查这份生成的本地声明与使用方包装函数。

为一个使用命名导出的JavaScript包补充类型;findCharge可能返回undefined,并且公开收据不得包含内部access token。

TypeScript
declare module "legacy-payments" {
  interface Charge {
    id: string;
    cents: number;
    accessToken: string;
  }

  function findCharge(id: string): Charge;
  const client: { findCharge: typeof findCharge };
  export default client;
}

import client from "legacy-payments";

type PublicReceipt = { id: string; cents: number };

export function publicReceipt(id: string) {
  const charge = client.findCharge(id);
  return charge;
}

生成代码仅作示例,不代表任何特定模型

在试验场中打开
报告错误