簡體   English   中英

打字稿 - 輸入接口?

[英]Typescript - Type an Interface?

如果這有點含糊,我很抱歉,因為我不是 100% 打字稿。 有沒有辦法向界面添加類型?

技術:Angular 9、Swagger 和 TypeScript。

這是錯誤的,但像這樣:

export interface PasswordRequest: components["schemas"]["PasswordRequest"] {}

我不是在尋找:

export interface PasswordRequest {
  email?: string | null;
  oldPassword?: string | null;
}

這是一個很長的故事,但基本上 swagger 正在被改造到舊的應用程序中。 它吐出來

    export interface components { schemas: { PasswordRequest: { email?: string | null; oldPassword?: string | null; newPassword?: string | null; };
with all the needed interface under this components > schemas structure.

我試圖避免翻錄/重命名接口和所有導入。

如果您使用類型來提取接口的相關部分,它應該可以工作

export type PasswordRequest  = components['schemas']['PasswordRequest']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM