Skip to content

parser(ts): implements and extends in classes and interfaces #12884

@armano2

Description

@armano2

This bug has no definitive answer and requires some dialog, personally i prefer AST generated by babel rather than typescript-eslint in this case

Bug Report?

babel for class implements and interface extends generates TSExpressionWithTypeArguments node that has fields expression and typeParameters -> this part matches with typescript itself but does not with typescript-estree as it has 2 separate nodes for TSClassImplements and TSInterfaceHeritage

as for expression babel in this case derives from what typescript does as it generates QualifiedName/Identifier and typescript-eslint follows typescript on this and generates expression.

I'm unsure witch direction we want to go with this, and its a thing that one team should decide

Example 1

class foo implements bar.baz() {
}

in this case babel is going to fail
typescript is going to parse this, report AST and optionally report semantic/synthetic error
typescript-eslint does not report semantic/synthetic errors by default as its costly than there is no error reported

Example 2

class foo implements bar {
}

all parser parse this code correctly, and report bar as identifier and only difference is that typescript-eslint produces TSInterfaceHeritage and babel TSExpressionWithTypeArguments

Additional examples

interface foo extends bar.baz<T> {
}
class foo extedns bar.baz()<T> implements bar.baz()<T> {
}

...

I'd like to hear opinion of babel team on this as this should be changed one way or another or both, as having unified structure should (or get closer to) enable use of babel as parser for eslint (for those who choose to do so).

i reported this as a bug but this is not really a bug, its a misalignment

cc @bradzacher @JLHwung @sosukesuzuki @fedeci

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions