gpt4 book ai didi

angular - 想要扩展空接口(interface)但得到 lint 错误 : no-empty-interface

转载 作者:行者123 更新时间:2023-12-03 16:43:02 30 4
gpt4 key购买 nike

今天,我尝试在我的 Angular 6 应用程序中执行此操作:

export interface AuthConfig {}

export interface BasicAuthConfig extends AuthConfig {
username: string;
password: string;
}

export interface OAuth2AuthConfig extends AuthConfig {
tokenName: string;
url: string;
callbackUrl: string;
clientId: string;
scope: string[];
grantType: grantTypes;
}

并得到一个 lint 错误:
An empty interface is equivalent to `{}`. (no-empty-interface)

我想用我的 Endpoint 接口(interface)来做到这一点:
Export interface Endpoint {

authConfig: AuthConfig;

}

但被简化为这样做:
Export interface Endpoint {

authConfig: BasicAuthConfig | OAuth2AuthConfig;

}

不同类型的授权可能会变得很长,因此我不想继续将类型附加到 Endpoint 接口(interface)的 authConfig 属性中。有没有什么方法可以声明一个空接口(interface)来扩展它而不会对我大喊大叫?

谢谢。

最佳答案

您可以在 tslint.json 中禁用此规则:

"rules": { "no-empty-interface": false }

或者只是禁用一行的 linting:
// tslint:disable-next-line
export interface AuthConfig {}

关于angular - 想要扩展空接口(interface)但得到 lint 错误 : no-empty-interface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55420228/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com