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

Add more tests for satisfies #13775

Merged
merged 5 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@angular/compiler": "14.2.8",
"@babel/code-frame": "7.18.6",
"@babel/parser": "7.20.0",
"@babel/parser": "7.20.1",
"@babel/types": "7.20.0",
"@glimmer/syntax": "0.84.2",
"@iarna/toml": "2.2.5",
Expand Down
6 changes: 1 addition & 5 deletions src/language-js/needs-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,7 @@ function needsParens(path, options) {
case "AssignmentPattern":
return (
key === "left" &&
(node.type === "TSTypeAssertion" ||
// babel-parser cannot parse `satisfies` operator in left side of assignment
// https://github.com/babel/babel/issues/15095
// TODO: Add tests after the bug is fixed
isTSTypeExpression(node))
(node.type === "TSTypeAssertion" || isTSTypeExpression(node))
);

case "LogicalExpression":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,61 @@ window.postMessage({
================================================================================
`;

exports[`lhs.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
printWidth: 80
semi: false
| printWidth
=====================================input======================================
(a satisfies number) = 42;
({ a: (b satisfies any) = 2000 } = x);
(this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined;
(this.configuration satisfies any) = (this.editor satisfies any) = (this
.editorBody satisfies any) = undefined;

=====================================output=====================================
;(a satisfies number) = 42
;({ a: (b satisfies any) = 2000 } = x)
;(this.selectorElem satisfies any) =
this.multiselectWidget =
this.initialValues =
undefined
;(this.configuration satisfies any) =
(this.editor satisfies any) =
(this.editorBody satisfies any) =
undefined

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

exports[`lhs.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
printWidth: 80
| printWidth
=====================================input======================================
(a satisfies number) = 42;
({ a: (b satisfies any) = 2000 } = x);
(this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined;
(this.configuration satisfies any) = (this.editor satisfies any) = (this
.editorBody satisfies any) = undefined;

=====================================output=====================================
(a satisfies number) = 42;
({ a: (b satisfies any) = 2000 } = x);
(this.selectorElem satisfies any) =
this.multiselectWidget =
this.initialValues =
undefined;
(this.configuration satisfies any) =
(this.editor satisfies any) =
(this.editorBody satisfies any) =
undefined;

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

exports[`nested-await-and-satisfies.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
Expand Down
5 changes: 5 additions & 0 deletions tests/format/typescript/satisfies-operators/lhs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(a satisfies number) = 42;
({ a: (b satisfies any) = 2000 } = x);
(this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined;
(this.configuration satisfies any) = (this.editor satisfies any) = (this
.editorBody satisfies any) = undefined;
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ __metadata:
languageName: node
linkType: hard

"@babel/parser@npm:7.20.0, @babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.18.10, @babel/parser@npm:^7.18.11":
version: 7.20.0
resolution: "@babel/parser@npm:7.20.0"
"@babel/parser@npm:7.20.1, @babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.18.10, @babel/parser@npm:^7.18.11":
version: 7.20.1
resolution: "@babel/parser@npm:7.20.1"
bin:
parser: ./bin/babel-parser.js
checksum: d54d68e45ff1b9a0c50a3f79d9031f482eb58f18928525949dc20da5b1658ee79167e756129371fd75d3e8fc7e218ab707727145a68958636be9672c7b71768e
checksum: 2db7ba692b8b3054df129876b115ed8b265d5c138dee5e1db56a999209df3dd3d508e0985bf3cc44fc432498da094c164906b531d049608e55e208dae0678d42
languageName: node
linkType: hard

Expand Down Expand Up @@ -6612,7 +6612,7 @@ __metadata:
"@angular/compiler": 14.2.8
"@babel/code-frame": 7.18.6
"@babel/generator": 7.20.0
"@babel/parser": 7.20.0
"@babel/parser": 7.20.1
"@babel/types": 7.20.0
"@esbuild-plugins/node-modules-polyfill": 0.1.4
"@glimmer/reference": 0.84.2
Expand Down