-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
No error thrown for a declare class field that have an initializer #12092
Copy link
Copy link
Closed
Labels
i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Bug Report
- I would like to work on a fix!
Current behavior
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", |
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue