转换 TypeScript 接口

问题描述 投票:0回答:0

我有一个包含类似接口的打字稿文件

export interface User { ... }
export interface Product { ... }
export interface Account { ... }

export interface MyType {
  id: number;
  userId: string;
  productId: string;
  accountId: string;
  propX: string;
  propY: number;
}

我想将具有以

Id
结尾的道具的界面转换为例如
MyType

export interface MyType {
  id: number;
  user: User;
  product: Product;
  account: Account;
  propX: string;
  propY: number;
}

或以这种方式更改界面:

export interface MyType {
  id: number;
  user: User;
  userId: string;
  product: Product;
  productId: string;
  account: Account;
  accountId: string;
  propX: string;
  propY: number;
}

我想基于包含接口定义的原始文件创建一个新文件。

最好的方法是什么?

typescript interface code-generation
© www.soinside.com 2019 - 2024. All rights reserved.