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

No error thrown for a declare class field that have an initializer #12092

Closed
1 task done
sosukesuzuki opened this issue Sep 22, 2020 · 1 comment · Fixed by #12093
Closed
1 task done

No error thrown for a declare class field that have an initializer #12092

sosukesuzuki opened this issue Sep 22, 2020 · 1 comment · Fixed by #12093
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@sosukesuzuki
Copy link
Member

Bug Report

  • I would like to work on a fix!

Current behavior

REPL

No error is thrown from parser. We can find an error message for this from source code(ref:

"'declare' class fields cannot have an initializer",
) but it isn't thrown.

We have a test for this but I think it is wrong because the AST have no errors (ref: https://github.com/babel/babel/blob/3628c528676a91cd95bb00d56f799be53185e316/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json)

Input Code

class A {
  declare bar: string = "test";
}

Expected behavior
It throw a syntax error "'declare' class fields cannot have an initializer".

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

parse(code, {  plugins: ["typescript", "classProperties"] });

Environment

Possible Solution

Additional context

@babel-bot
Copy link
Collaborator

Hey @sosukesuzuki! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Dec 23, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants