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 @typescript-eslint/typescript-estree to support satisfies #13872

Merged
merged 8 commits into from Nov 22, 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
10 changes: 6 additions & 4 deletions changelog_unreleased/typescript/13764.md
@@ -1,10 +1,8 @@
#### Support TypeScript 4.9 (#13764, #13783 by @sosukesuzuki)
#### Support TypeScript 4.9 (#13764, #13783, #13872 by @sosukesuzuki)
Copy link
Member

@kachkaev kachkaev Nov 21, 2022

Choose a reason for hiding this comment

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

How about this header instead?

Suggested change
#### Support TypeScript 4.9 (#13764, #13783, #13872 by @sosukesuzuki)
#### Support TypeScript 4.9 `satisfies` operator (#13764, #13783, #13872 by @sosukesuzuki)
Suggested change
#### Support TypeScript 4.9 (#13764, #13783, #13872 by @sosukesuzuki)
#### Support TypeScript 4.9 [`satisfies`](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#satisfies) operator (#13764, #13783, #13872 by @sosukesuzuki)

Otherwise we start with an overpromise. Instead of adding a header for Auto-Accessors in Classes we can say something like:

[Auto-Accessors in Classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#auto-accessors-in-classes) will be supported in an upcoming 2.8 patch release. We have de-scoped them for now to ship `satisfies` operator sooner.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Isn't it already supported by babel-ts parser? User can switch to use it temporarily.

Copy link
Member Author

Choose a reason for hiding this comment

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

@babel/parser can parse auto accessors. But it cannot be used with type annotations to we need to wait babel/babel#15209


Support [TypeScript 4.9](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9) features!

##### [`satisfies` operator](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9-beta/#the-satisfies-operator)

Supported by only `babel-ts` parser.
##### [`satisfies` operator](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#satisfies)

<!-- prettier-ignore -->
```tsx
Expand All @@ -14,3 +12,7 @@ const palette = {
blue: [0, 0, 255]
} satisfies Record<Colors, string | RGB>;
```

##### [Auto-Accessors in Classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#auto-accessors-in-classes)

**Auto-Accessors in Classes is not yet supported.**
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -27,7 +27,7 @@
"@babel/parser": "7.20.1",
"@glimmer/syntax": "0.84.2",
"@iarna/toml": "2.2.5",
"@typescript-eslint/typescript-estree": "5.36.2",
"@typescript-eslint/typescript-estree": "5.44.0",
"acorn": "8.8.0",
"acorn-jsx": "5.3.2",
"angular-estree-parser": "2.5.1",
Expand Down
1 change: 0 additions & 1 deletion src/language-js/utils/index.js
Expand Up @@ -998,7 +998,6 @@ function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
node.expressions[0],
forbidFunctionClassAndDoExpr
);
// @ts-expect-error
case "TSSatisfiesExpression":
case "TSAsExpression":
case "TSNonNullExpression":
Expand Down
Expand Up @@ -2,7 +2,7 @@

exports[`argument-expansion.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -59,7 +59,7 @@ const bar5 = [1, 2, 3].reduce((carry, value) => {

exports[`argument-expansion.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand Down Expand Up @@ -115,7 +115,7 @@ const bar5 = [1, 2, 3].reduce((carry, value) => {

exports[`assignment.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -171,7 +171,7 @@ this.intervalID = setInterval(() => {

exports[`assignment.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand Down Expand Up @@ -226,7 +226,7 @@ this.intervalID = setInterval(() => {

exports[`basic.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -299,7 +299,7 @@ var v = undefined satisfies 1

exports[`basic.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand Down Expand Up @@ -371,7 +371,7 @@ var v = undefined satisfies 1;

exports[`comments.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand All @@ -390,7 +390,7 @@ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}

exports[`comments.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -408,7 +408,7 @@ const t4 = {} /* comment1 */ satisfies /* comment2 */ {};

exports[`comments-unstable.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand All @@ -434,7 +434,7 @@ Record<string, number>

exports[`comments-unstable.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -459,7 +459,7 @@ Record<string, number>;

exports[`export-default-as.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand All @@ -474,7 +474,7 @@ export default (function log() {} satisfies typeof console.log)

exports[`export-default-as.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -488,7 +488,7 @@ export default (function log() {} satisfies typeof console.log);

exports[`gt-lt.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand All @@ -505,7 +505,7 @@ x satisfies boolean ?? y; // (x satisfies boolean) ?? y;

exports[`gt-lt.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -521,7 +521,7 @@ x satisfies boolean ?? y; // (x satisfies boolean) ?? y;

exports[`hug-args.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand All @@ -544,7 +544,7 @@ window.postMessage({

exports[`hug-args.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -566,7 +566,7 @@ window.postMessage({

exports[`lhs.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -594,7 +594,7 @@ semi: false

exports[`lhs.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -621,7 +621,7 @@ printWidth: 80

exports[`nested-await-and-satisfies.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -649,7 +649,7 @@ const getAccountCount = async () =>

exports[`nested-await-and-satisfies.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -676,7 +676,7 @@ const getAccountCount = async () =>

exports[`non-null.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand All @@ -695,7 +695,7 @@ const el = ReactDOM.findDOMNode(ref)

exports[`non-null.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand All @@ -713,7 +713,7 @@ const el = ReactDOM.findDOMNode(ref);

exports[`satisfies.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -770,7 +770,7 @@ foo as unknown satisfies Bar

exports[`satisfies.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand Down Expand Up @@ -826,7 +826,7 @@ foo as unknown satisfies Bar;

exports[`template-literal.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -858,7 +858,7 @@ const b = \`\${

exports[`template-literal.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand Down Expand Up @@ -889,7 +889,7 @@ const b = \`\${

exports[`ternary.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand Down Expand Up @@ -992,7 +992,7 @@ bifornCringerMoshedPerplexSawder =

exports[`ternary.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand Down Expand Up @@ -1094,7 +1094,7 @@ bifornCringerMoshedPerplexSawder =

exports[`types-comments.ts - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
semi: false
| printWidth
Expand All @@ -1113,7 +1113,7 @@ semi: false

exports[`types-comments.ts format 1`] = `
====================================options=====================================
parsers: ["babel-ts"]
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Expand Down
4 changes: 2 additions & 2 deletions tests/format/typescript/satisfies-operators/jsfmt.spec.js
@@ -1,2 +1,2 @@
run_spec(__dirname, ["babel-ts"]);
run_spec(__dirname, ["babel-ts"], { semi: false });
run_spec(__dirname, ["typescript"]);
run_spec(__dirname, ["typescript"], { semi: false });