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

Parses invalid class code #4072

Closed
3 tasks done
ljharb opened this issue Oct 30, 2021 · 1 comment
Closed
3 tasks done

Parses invalid class code #4072

ljharb opened this issue Oct 30, 2021 · 1 comment
Labels
duplicate This issue or pull request already exists package: parser Issues related to @typescript-eslint/parser

Comments

@ljharb
Copy link

ljharb commented Oct 30, 2021

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

        class Foo extends React.Component {
          contructor(props) {
            super(props);
            this.initialValues = {
              test: '',
            };
          }

          render = () => {
            return (
              <Component
                initialValues={this.props.initialValues || this.initialValues}
              >
                {formikProps => (
                  <Input {...formikProps} />
                )}
              </Component>
            );
          }
        }

Expected Result

A parse error, because super() is not valid except in constructor() {} and this is contructor() {}

Actual Result

No parse error.

Additional Info

Confusion over this led me to file eslint/eslint#15234, but eslint 8 is actually handling this correctly because of the typo.

Related: babel/babel#13903

Versions

package version
@typescript-eslint/parser 5.2.0
TypeScript 3.9.10
ESLint 8.1.0
node 17.0.1
@ljharb ljharb added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels Oct 30, 2021
@bradzacher
Copy link
Member

#1852

We are built on top of TS's parser, which is designed to be "forgiving" so it can handle incomplete code in usecases like an IDE.

We would like to add strict enforcement that when we convert the AST to ESTree it is done so it strictly adheres to the spec, but we haven't had the bandwidth for that yet.

@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for maintainers to take a look labels Oct 30, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2021
@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

No branches or pull requests

3 participants