8000 Bug: Duplicate `extends` clause for `interface` should be reported · Issue #11077 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: Duplicate extends clause for interface should be reported #11077

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

Open
4 tasks done
leaysgur opened this issue Apr 15, 2025 · 3 comments
Open
4 tasks done

Bug: Duplicate extends clause for interface should be reported #11077

leaysgur opened this issue Apr 15, 2025 · 3 comments
Labels
accepting prs Go ahead, send a pull request that resolves this issue AST PRs and Issues about the AST structure bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@leaysgur
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

typescript-estree

Playground Link

https://typescript-eslint.io/play/#ts=5.4.3&fileType=.tsx&code=MYGwhgzhAECiCM0DeBfAUKSNYCZno3CmgA1EBTADwBdyA7AE20VTQHo3pNiS8rbGzaP3pM4eVtxgkAzNACWAWwAOIcovrUhrDlyLSALApVqNdLXERLV6zdgnoppAKzCaooddN3x%2BdpycSADZjGzMLBDcBMVw-NHlzcgAnADMwYHJoAE0Kd0FLPwTaVPTMrL48mNzo%2B3xoXUBeDcABHegAFQALeRgIdoB7AFcQBmgAI0yk8mVepNphkYBPaGUwJIhkgBpoEHkAa0ze6nbkiH8FRJKM7LkvW3NtdF0i5LTLrKMb8M8TW4iHU6eLmVXB8fJERPlYjpOACXmUQuCqqFvHdfKggA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

class E1 {}
class E2 {}

// class X2 extends E1 extends E2 {} // This is reported
interface Y2 extends E1 extends E2 {} // This is NOT reported

ESLint Config

tsconfig

Expected Result

Parser should report internal error TS1172: 'extends' clause already seen. like TS does.

https://www.typescriptlang.org/play/?#code/MYGwhgzhAECiCM0DeBfAUKSNYCZno3CmgA1EBTADwBdyA7AE20VTQHo3pNiS8rbGzaP3pM4eVtxgkAzNACWAWwAOIcovrUhrDlyLSALApVqNdLXERLV6zdgnoppAKzCaooddN3x+dpycSADZjGzMLBDcBMVw-NHlzcgAnADMwYHJoAE0Kd0FLPwTaVPTMrL48mNzo+z9dIuS0jOy5L1tzbXR6xJLmrKM28M8TdoiHfwUeprLXQZ9IkXzYnU4G3rKQxarQ7w7fVCA

Actual Result

No errors are reported.

Additional Info

Since duplicate extends are reported correctly for class, they should be reported for interface too?

if (token === SyntaxKind.ExtendsKeyword) {
if (extendsClause) {
this.#throwUnlessAllowInvalidAST(
heritageClause,
"'extends' clause already seen.",
);
}

I can send a PR if this is acceptable change.

leaysgur@0a6d4db

Versions

package version
@typescript-eslint/typescript-estree 8.30.1
@leaysgur leaysgur added bug Something isn't working triage Waiting for team members to take a look labels Apr 15, 2025
@bradzacher
Copy link
Member

I would direct you towards my reply on your last issue #11064 (comment)

TS allows a myriad of combinations of invalid syntax - most of which we don't explicitly fail on either. Linting code with any TS errors is considered "undefined behaviour".

The reason we have errors for classes is because there's some syntactical ordering to classes that should hold true - eg implements comes after extends - and us implementing the checks was easier than downstream consumers like prettier implementing the checks. And considering we were adding a few checks adding more was easy and made sense.

It's really a question of what is to be gained from adding the errors. Why do you think this should be an explicit and hard crash?

@bradzacher bradzacher added package: typescript-estree Issues related to @typescript-eslint/typescript-estree awaiting response Issues waiting for a reply from the OP or another party AST PRs and Issues about the AST structure and removed triage Waiting for team members to take a look labels Apr 15, 2025
@leaysgur
Copy link
Author
leaysgur commented Apr 16, 2025

Thank you for your continued kindness. 🙏

Why do you think this should be an explicit and hard crash?

This was motivated by:

  • For interface
  • duplicate implements are reported as internal error
  • But, why duplicate extends are not?

I was simply concerned about these difference.

(If you feel this is a kind of maintenance burden, feel free to close this. Sorry in that case.)

@JoshuaKGoldberg JoshuaKGoldberg changed the title Bug: Duplicate extends caluse for interface should be reported Bug: Duplicate extends clause for interface should be reported Apr 18, 2025
@JoshuaKGoldberg JoshuaKGoldberg added triage Waiting for team members to take a look and removed awaiting response Issues waiting for a reply from the OP or another party labels Apr 18, 2025
@JoshuaKGoldberg
Copy link
Member

Agreed. As with #11088, 👍 from me on adding slightly more sanitization to the AST.

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue AST PRs and Issues about the AST structure bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

No branches or pull requests

3 participants
0