-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Wrong error message: SyntaxError: Cannot read property 'type' of undefined (0:0) #9226
Copy link
Copy link
Closed
Closed
Copy link
Labels
lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency
Description
Environments:
- Prettier Version: 2.1.2
- Running Prettier via: CLI
- Runtime: Node.js v12.16.1
- Operating System: macOS
Steps to reproduce:
cat <<_EOF > sample.js
const p = {
set name(){}
};
_EOF
npx prettier@2.1.2 sample.jsExpected behavior:
SyntaxError: setter must have exactly one formal parameter (2:3) is expected.
npx prettier@1.18.2 sample.js
sample.js[error] sample.js: SyntaxError: setter must have exactly one formal parameter (2:3)
[error] 1 | const p = {
[error] > 2 | set name(){}
[error] | ^
[error] 3 | };
[error] 4 |
Actual behavior:
npx prettier@2.1.2 sample.js
sample.js[error] sample.js: SyntaxError: Cannot read property 'type' of undefined (0:0)
[error] 1 | const p = {
[error] 2 | set name(){}
[error] 3 | };
FYI
It looks babel/parser throws right error but Prettier fails to parse the babel/parser error. may be.
npx @babel/parser sample.js
setter must have exactly one formal parameter (2:2)
Thank you
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency