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

Update @babel/parser to 7.12 #9408

Merged
merged 27 commits into from Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c87b672
Install babel/parser 7.12
sosukesuzuki Oct 15, 2020
b5308bd
Add tests for babel/babel#12161
sosukesuzuki Oct 15, 2020
7979066
Add test for babel/babel#12076
sosukesuzuki Oct 15, 2020
b19743f
Add test for babel/babel#12085
sosukesuzuki Oct 15, 2020
d599e72
Add test for babel/babel#12108
sosukesuzuki Oct 15, 2020
7417d90
Add test for babel/babel#12120
sosukesuzuki Oct 15, 2020
cf0ed63
Add test for babel/babel#12054
sosukesuzuki Oct 15, 2020
2e42f06
Add test for babel/babel#12061
sosukesuzuki Oct 15, 2020
6c20b0d
Add test babel/babel#12093
sosukesuzuki Oct 15, 2020
58cbf8b
Add test for babel/babel#12065
sosukesuzuki Oct 15, 2020
cab1ee7
Add test for babel/babel#12111
sosukesuzuki Oct 16, 2020
e418282
Add test for babel/babel#12072
sosukesuzuki Oct 16, 2020
d2365f6
Switch syntax-module-attributes to syntax-import-assertion
sosukesuzuki Oct 18, 2020
26ec800
Support "String import/export specifier"
sosukesuzuki Oct 18, 2020
9eb8275
Merge branch 'master' into babel-7.12.0
sosukesuzuki Oct 18, 2020
ac9f558
Remove tests for module-attributes
sosukesuzuki Oct 18, 2020
71128fe
Add changelog
sosukesuzuki Oct 19, 2020
766c4cf
Update to 7.12.3
sosukesuzuki Oct 19, 2020
c06180e
Fix by linter
sosukesuzuki Oct 19, 2020
b1558d1
Fix by spellchecker
sosukesuzuki Oct 19, 2020
6452008
Add tests for module attributes to errors
sosukesuzuki Oct 19, 2020
f1182e7
Add error test for module string name with import
sosukesuzuki Oct 19, 2020
226b1db
Remove TSTypeCastExpression
sosukesuzuki Oct 19, 2020
bc5251d
Add tests for funny import-assertions
sosukesuzuki Oct 19, 2020
0fddd9a
Merge branch 'master' into babel-7.12.0
sosukesuzuki Oct 20, 2020
7042f57
Update snapshots|
sosukesuzuki Oct 20, 2020
aaa7326
Add more tests
sosukesuzuki Oct 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@angular/compiler": "10.1.5",
"@babel/code-frame": "7.10.4",
"@babel/parser": "7.11.5",
"@babel/parser": "7.12.0",
"@glimmer/syntax": "0.62.1",
"@iarna/toml": "2.2.5",
"@typescript-eslint/typescript-estree": "3.10.1",
Expand Down
6 changes: 4 additions & 2 deletions src/language-js/printer-estree.js
Expand Up @@ -913,7 +913,8 @@ function printPathNoParens(path, options, print, args) {
parent.type === "DoWhileStatement" ||
parent.type === "DoExpression" ||
(parent.type === "CatchClause" && !parentParent.finalizer) ||
parent.type === "TSModuleDeclaration")
parent.type === "TSModuleDeclaration" ||
parent.type === "TSDeclareFunction")
) {
return "{}";
}
Expand Down Expand Up @@ -2886,7 +2887,8 @@ function printPathNoParens(path, options, print, args) {

return group(concat(parts));
}
case "TypeCastExpression": {
case "TypeCastExpression":
case "TSTypeCastExpression": {
Copy link
Member

Choose a reason for hiding this comment

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

This case isn't needed. The AST shouldn't contain such nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

226b1db 👍

return concat([
"(",
path.call(print, "expression"),
Expand Down
14 changes: 14 additions & 0 deletions tests/js/objects/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -143,6 +143,20 @@ printWidth: 80
================================================================================
`;

exports[`invalid-setter.js format 1`] = `
====================================options=====================================
parsers: ["babel"]
printWidth: 80
| printWidth
=====================================input======================================
({ set x(){} });

=====================================output=====================================
({ set x() {} });

================================================================================
`;

exports[`method.js format 1`] = `
====================================options=====================================
parsers: ["babel"]
Expand Down
1 change: 1 addition & 0 deletions tests/js/objects/invalid-setter.js
@@ -0,0 +1 @@
({ set x(){} });
8 changes: 7 additions & 1 deletion tests/js/objects/jsfmt.spec.js
@@ -1,3 +1,9 @@
run_spec(__dirname, ["babel"], {
errors: { espree: ["expression.js", "invalid-accessor-generator.js"] },
errors: {
espree: [
"expression.js",
"invalid-accessor-generator.js",
"invalid-setter.js",
],
},
});
14 changes: 14 additions & 0 deletions tests/js/variable_declarator/__snapshots__/jsfmt.spec.js.snap
@@ -1,5 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`invalid-const.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
const foo;

=====================================output=====================================
const foo;

================================================================================
`;

exports[`multiple.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
Expand Down
1 change: 1 addition & 0 deletions tests/js/variable_declarator/invalid-const.js
@@ -0,0 +1 @@
const foo;
7 changes: 6 additions & 1 deletion tests/js/variable_declarator/jsfmt.spec.js
@@ -1 +1,6 @@
run_spec(__dirname, ["babel", "flow", "typescript"]);
run_spec(__dirname, ["babel", "flow", "typescript"], {
errors: {
espree: ["invalid-const.js"],
flow: ["invalid-const.js"],
},
});
8 changes: 4 additions & 4 deletions tests/misc/errors/babel-ts/__snapshots__/jsfmt.spec.js.snap
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`issue-8041.ts error test 1`] = `
"Did not expect a type annotation here. (1:2)
> 1 | (a:b)
| ^
exports[`type-annotation.ts error test 1`] = `
"Did not expect a type annotation here. (1:9)
> 1 | func<T>(a: T);
| ^
Copy link
Member

Choose a reason for hiding this comment

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

Why does Babel parse (a:b) without errors now?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I found babel/babel#12185
So this test should stay.

2 | "
`;
1 change: 0 additions & 1 deletion tests/misc/errors/babel-ts/issue-8041.ts

This file was deleted.

1 change: 1 addition & 0 deletions tests/misc/errors/babel-ts/type-annotation.ts
@@ -0,0 +1 @@
func<T>(a: T);
8 changes: 8 additions & 0 deletions tests/typescript/class/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -21,6 +21,10 @@ class A {
}
}

class B {
constructor<>() {}
Copy link
Member

Choose a reason for hiding this comment

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

Will it work if there are comments inside?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, class constructor in TypeScript does not accept type parameterss.

}

=====================================output=====================================
class foo {
constructor(static a: number) {}
Expand All @@ -37,6 +41,10 @@ class A {
}
}

class B {
constructor<>() {}
}

================================================================================
`;

Expand Down
4 changes: 4 additions & 0 deletions tests/typescript/class/constructor.ts
Expand Up @@ -12,3 +12,7 @@ class A {
return new A()
}
}

class B {
constructor<>() {}
}
Expand Up @@ -10,13 +10,16 @@ class c3 {
constructor(public arg: number = 10) {
// fails because of comment
}
not_constructor(public arg: number = 10) {
}
}

=====================================output=====================================
class c3 {
constructor(public arg: number = 10) {
// fails because of comment
}
not_constructor(public arg: number = 10) {}
}

================================================================================
Expand Down
Expand Up @@ -2,4 +2,6 @@ class c3 {
constructor(public arg: number = 10) {
// fails because of comment
}
not_constructor(public arg: number = 10) {
}
}
82 changes: 82 additions & 0 deletions tests/typescript/declare/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -8,6 +8,12 @@ printWidth: 80
=====================================input======================================
class B {p: number;}
class C extends B {declare p: 256 | 1000;}
class D {
declare field = "field";
}
declare class D {
field = "field";
}

=====================================output=====================================
class B {
Expand All @@ -16,6 +22,12 @@ class B {
class C extends B {
declare p: 256 | 1000;
}
class D {
declare field = "field";
}
declare class D {
field = "field";
}

================================================================================
`;
Expand Down Expand Up @@ -50,6 +62,8 @@ declare namespace A {
function y(): void;
}

declare function f([]?)

=====================================output=====================================
declare function x();
declare function y(): void;
Expand All @@ -59,6 +73,30 @@ declare namespace A {
function y(): void;
}

declare function f([]?);

================================================================================
`;

exports[`declare_function_with_body.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
// Invalid, but recoverable
declare function foo() {}
declare function bar() {
// comment
}

=====================================output=====================================
// Invalid, but recoverable
declare function foo() {};
declare function bar() {
// comment
};

================================================================================
`;

Expand All @@ -80,6 +118,50 @@ declare interface Dictionary<T> {
================================================================================
`;

exports[`declare_module.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
declare module m {
class C {
field = "field";
}
}

=====================================output=====================================
declare module m {
class C {
field = "field";
}
}

================================================================================
`;

exports[`declare_namespace.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
declare namespace m {
class C {
field = "field";
}
}

=====================================output=====================================
declare namespace m {
class C {
field = "field";
}
}

================================================================================
`;

exports[`declare_var.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
Expand Down
6 changes: 6 additions & 0 deletions tests/typescript/declare/declare_class_fields.ts
@@ -1,2 +1,8 @@
class B {p: number;}
class C extends B {declare p: 256 | 1000;}
class D {
declare field = "field";
}
declare class D {
field = "field";
}
2 changes: 2 additions & 0 deletions tests/typescript/declare/declare_function.ts
Expand Up @@ -5,3 +5,5 @@ declare namespace A {
function x();
function y(): void;
}

declare function f([]?)
5 changes: 5 additions & 0 deletions tests/typescript/declare/declare_function_with_body.ts
@@ -0,0 +1,5 @@
// Invalid, but recoverable
declare function foo() {}
declare function bar() {
// comment
}
5 changes: 5 additions & 0 deletions tests/typescript/declare/declare_module.ts
@@ -0,0 +1,5 @@
declare module m {
class C {
field = "field";
}
}
5 changes: 5 additions & 0 deletions tests/typescript/declare/declare_namespace.ts
@@ -0,0 +1,5 @@
declare namespace m {
class C {
field = "field";
}
}
7 changes: 6 additions & 1 deletion yarn.lock
Expand Up @@ -279,7 +279,12 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/parser@7.11.5", "@babel/parser@^7.1.0", "@babel/parser@^7.10.4", "@babel/parser@^7.11.5", "@babel/parser@^7.7.0":
"@babel/parser@7.12.0":
version "7.12.0"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.0.tgz#2ad388f3960045b22f9b7d4bf85e80b15a1c9e3a"
integrity sha512-dYmySMYnlus2jwl7JnnajAj11obRStZoW9cG04wh4ZuhozDn11tDUrhHcUZ9iuNHqALAhh60XqNaYXpvuuE/Gg==

"@babel/parser@^7.1.0", "@babel/parser@^7.10.4", "@babel/parser@^7.11.5", "@babel/parser@^7.7.0":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.5.tgz#c7ff6303df71080ec7a4f5b8c003c58f1cf51037"
integrity sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==
Expand Down