Today, I tried to do this in my angular 6 application:
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;
}
And got a lint error:
An empty interface is equivalent to `{}`. (no-empty-interface)
I wanted to do this with my Endpoint interface:
Export interface Endpoint {
…
authConfig: AuthConfig;
…
}
But was reduced to doing this:
Export interface Endpoint {
…
authConfig: BasicAuthConfig | OAuth2AuthConfig;
…
}
The different types of authorization could get lengthy so I don’t want to keep tacking on the types to the authConfig property of the Endpoint interface. Is there any way to declare an empty interface for the purpose of extending it without lint yelling at me?
Thanks.
You can either disable this rule in tslint.json
:
"rules": { "no-empty-interface": false }
Or just disable linting for one line:
// tslint:disable-next-line
export interface AuthConfig {}
Example:
$ cat .eslintrc.js
...
"rules": {
'@typescript-eslint/no-empty-interface': 'off'
}
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With