8000 [no-empty-interface] Disable in declaration merging contexts · Issue #1875 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

[no-empty-interface] D 8000 isable in declaration merging contexts #1875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kripod opened this issue Apr 9, 2020 · 2 comments · Fixed by #1880
Closed

[no-empty-interface] Disable in declaration merging contexts #1875

kripod opened this issue Apr 9, 2020 · 2 comments · Fixed by #1880
Labels
bug Something isn't working good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@kripod
Copy link
Contributor
kripod commented Apr 9, 2020

Repro

{
  "rules": {
    "@typescript-eslint/no-empty-interface": "error"
  }
}
import { tokens } from './theme.treat';

declare module 'treat/theme' {
  type Tokens = typeof tokens;
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
  export interface Theme extends Tokens {}
}

The code above can be found here, along with the referenced theme.treat.ts file in the same directory.

Expected Result

No errors should be thrown, as the Theme interface of module 'treat/theme' is being augmented.

Actual Result

An interface declaring no members is equivalent to its supertype.

(As thrown by @typescript-eslint/no-empty-interface.)

Additional Info

The code above gets auto-fixed to:

import { tokens } from './theme.treat';

declare module 'treat/theme' {
  type Tokens = typeof tokens;
  export type Theme = Tokens;
}

Which throws a TypeScript error ts(2300):

Duplicate identifier 'Theme'.

Versions

package version
@typescript-eslint/eslint-plugin 2.27.0
@typescript-eslint/parser 2.27.0
TypeScript 3.8.3
ESLint 6.8.0
node 13.12.0
yarn 1.22.4
npm 6.14.4
@kripod kripod added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 9, 2020
@bradzacher
Copy link
Member

This isn't really doable, because is that every single context is a declaration merging context.

I don't think disabling the rule entirely is the correct course of action, anyways - I'd rather have the rule knowingly and rarely false positive instead of false negative
Narrowing the scope of this down - we could do something when we detect an interface is within an ambient declaration (i.e. is a child of TSModuleDeclaration with declare: true).

I think it would be a good idea to use a suggestion fixer instead of an auto fixer when we detect this case.

Happy to accept a PR to make this happen!

@bradzacher bradzacher added bug Something isn't working good first issue Good for newcomers and removed triage Waiting for team members to take a look labels Apr 9, 2020
@greyscaled
Copy link
Contributor

I took a crack at it from what I understand of the situation ^

@bradzacher bradzacher added the has pr there is a PR raised to close this label Apr 11, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0