Skip to content
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

fix(typescript): report E0429 for class 'extends' clause #1116

Closed

Conversation

arieldon
Copy link
Contributor

This closes #1114.

It matches functionality of implements and interface ... extends by reporting an error when the user defines a class that uses a generic within an extends clause without a space between < like so <<.

For clarity, quick-lint-js reports an error in the following snippet that uses <<.

export class D<T> {}
export class D2 extends D<<U>() => number> {}

quick-lint-js does not report an error in this snippet since it uses < <.

export class D<T> {}
export class D2 extends D< <U>() => number> {}

Match functionality of `implements` and `interface ... extends` by
reporting an error when the user defines a class that uses a generic
within an `extends` clause without a space between `<` like so `<<`.

For clarity, quick-lint-js reports an error in the following snippet
that uses `<<`.
```
export class D<T> {}
export class D2 extends D<<U>() => number> {}
```

quick-lint-js does _not_ report an error in this snippet since it uses
`< <`.
```
export class D<T> {}
export class D2 extends D< <U>() => number> {}
```
@arieldon arieldon force-pushed the report_e0429_for_extends_clause branch from cdffac8 to 1f49f7c Compare December 15, 2023 15:43
Copy link
Collaborator

@strager strager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@@ -1511,9 +1511,22 @@ Expression* Parser::parse_expression_remainder(Parse_Visitor_Base& v,
case Token_Type::less:
case Token_Type::less_less:
if (this->options_.typescript) {
// class C< <T>() => RetType> // Valid.
// class C<<T>() => RetType> // Invalid.
if (prec.in_class_extends_clause &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, I didn't know we had in_class_extends_clause. That makes this so easy!

@strager
Copy link
Collaborator

strager commented Dec 17, 2023

Landed as commit 58d0516.

@strager strager closed this Dec 17, 2023
@arieldon arieldon deleted the report_e0429_for_extends_clause branch December 23, 2023 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8$: report E0429 for class 'extends' clause
2 participants