Support TypeScript 4.4 (#11426)
* Update to ts-estree 4.30 * Add tests * Add changelog
This commit is contained in:
1 parent
6a5efe7fa8
commit
6dd2788e85
8 files changed
+218
-16
No files matched your search
@@ -0,0 +1,45 @@
|
||||
#### Support TypeScript 4.4 (#11426 by @sosukesuzuki)
|
||||
|
||||
Support [TypeScript 4.4](https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/)!
|
||||
|
||||
##### [`static` Blocks in Classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#static-blocks)
|
||||
|
||||
Class Static Blocks syntax is a Stage 3 ECMAScript proposal. See https://github.com/tc39/proposal-class-static-block for more details.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
class Foo {
|
||||
static count = 0;
|
||||
|
||||
// This is a static block:
|
||||
static {
|
||||
if (someCondition()) {
|
||||
Foo.count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
SyntaxError: Declaration expected. (5:9)
|
||||
3 |
|
||||
4 | // This is a static block:
|
||||
> 5 | static {
|
||||
| ^
|
||||
6 | if (someCondition()) {
|
||||
7 | Foo.count++;
|
||||
8 | }
|
||||
|
||||
// Prettier main
|
||||
class Foo {
|
||||
static count = 0;
|
||||
|
||||
// This is a static block:
|
||||
static {
|
||||
if (someCondition()) {
|
||||
Foo.count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
"@babel/parser": "7.15.3",
|
||||
"@glimmer/syntax": "0.80.0",
|
||||
"@iarna/toml": "2.2.5",
|
||||
"@typescript-eslint/typescript-estree": "4.29.3",
|
||||
"@typescript-eslint/typescript-estree": "4.30.0",
|
||||
"angular-estree-parser": "2.5.0",
|
||||
"angular-html-parser": "1.8.0",
|
||||
"camelcase": "6.2.0",
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`multiple.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "babel-ts"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
class Foo {
|
||||
static prop = 1
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
class Foo {
|
||||
static prop = 1;
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`nested.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "babel-ts"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
function foo () {
|
||||
return class {
|
||||
static foo = 1;
|
||||
static {
|
||||
const c = class {
|
||||
static bar = 2;
|
||||
static {
|
||||
// do
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
function foo() {
|
||||
return class {
|
||||
static foo = 1;
|
||||
static {
|
||||
const c = class {
|
||||
static bar = 2;
|
||||
static {
|
||||
// do
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`static-blocks.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "babel-ts"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
class Foo {
|
||||
static #count = 0;
|
||||
|
||||
get count() {
|
||||
return Foo.#count;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
const lastInstances = loadLastInstances();
|
||||
Foo.#count += lastInstances.length;
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
class Foo {
|
||||
static #count = 0;
|
||||
|
||||
get count() {
|
||||
return Foo.#count;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
const lastInstances = loadLastInstances();
|
||||
Foo.#count += lastInstances.length;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1 @@
|
||||
run_spec(__dirname, ["typescript", "babel-ts"]);
|
||||
@@ -0,0 +1,12 @@
|
||||
class Foo {
|
||||
static prop = 1
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
static {
|
||||
console.log(Foo.prop++);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
function foo () {
|
||||
return class {
|
||||
static foo = 1;
|
||||
static {
|
||||
const c = class {
|
||||
static bar = 2;
|
||||
static {
|
||||
// do
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Foo {
|
||||
static #count = 0;
|
||||
|
||||
get count() {
|
||||
return Foo.#count;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
const lastInstances = loadLastInstances();
|
||||
Foo.#count += lastInstances.length;
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
}
|
||||
@@ -1762,10 +1762,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.26.1.tgz#9e7c523f73c34b04a765e4167ca5650436ef1d38"
|
||||
integrity sha512-STyMPxR3cS+LaNvS8yK15rb8Y0iL0tFXq0uyl6gY45glyI7w0CsyqyEXl/Fa0JlQy+pVANeK3sbwPneCbWE7yg==
|
||||
|
||||
"@typescript-eslint/types@4.29.3":
|
||||
version "4.29.3"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.29.3.tgz#d7980c49aef643d0af8954c9f14f656b7fd16017"
|
||||
integrity sha512-s1eV1lKNgoIYLAl1JUba8NhULmf+jOmmeFO1G5MN/RBCyyzg4TIOfIOICVNC06lor+Xmy4FypIIhFiJXOknhIg==
|
||||
"@typescript-eslint/types@4.30.0":
|
||||
version "4.30.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.30.0.tgz#fb9d9b0358426f18687fba82eb0b0f869780204f"
|
||||
integrity sha512-YKldqbNU9K4WpTNwBqtAerQKLLW/X2A/j4yw92e3ZJYLx+BpKLeheyzoPfzIXHfM8BXfoleTdiYwpsvVPvHrDw==
|
||||
|
||||
"@typescript-eslint/typescript-estree@4.26.1":
|
||||
version "4.26.1"
|
||||
@@ -1780,13 +1780,13 @@
|
||||
semver "^7.3.5"
|
||||
tsutils "^3.21.0"
|
||||
|
||||
"@typescript-eslint/typescript-estree@4.29.3":
|
||||
version "4.29.3"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.3.tgz#1bafad610015c4ded35c85a70b6222faad598b40"
|
||||
integrity sha512-45oQJA0bxna4O5TMwz55/TpgjX1YrAPOI/rb6kPgmdnemRZx/dB0rsx+Ku8jpDvqTxcE1C/qEbVHbS3h0hflag==
|
||||
"@typescript-eslint/typescript-estree@4.30.0":
|
||||
version "4.30.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.30.0.tgz#ae57833da72a753f4846cd3053758c771670c2ac"
|
||||
integrity sha512-6WN7UFYvykr/U0Qgy4kz48iGPWILvYL34xXJxvDQeiRE018B7POspNRVtAZscWntEPZpFCx4hcz/XBT+erenfg==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.29.3"
|
||||
"@typescript-eslint/visitor-keys" "4.29.3"
|
||||
"@typescript-eslint/types" "4.30.0"
|
||||
"@typescript-eslint/visitor-keys" "4.30.0"
|
||||
debug "^4.3.1"
|
||||
globby "^11.0.3"
|
||||
is-glob "^4.0.1"
|
||||
@@ -1801,12 +1801,12 @@
|
||||
"@typescript-eslint/types" "4.26.1"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@4.29.3":
|
||||
version "4.29.3"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.3.tgz#c691760a00bd86bf8320d2a90a93d86d322f1abf"
|
||||
integrity sha512-MGGfJvXT4asUTeVs0Q2m+sY63UsfnA+C/FDgBKV3itLBmM9H0u+URcneePtkd0at1YELmZK6HSolCqM4Fzs6yA==
|
||||
"@typescript-eslint/visitor-keys@4.30.0":
|
||||
version "4.30.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.30.0.tgz#a47c6272fc71b0c627d1691f68eaecf4ad71445e"
|
||||
integrity sha512-pNaaxDt/Ol/+JZwzP7MqWc8PJQTUhZwoee/PVlQ+iYoYhagccvoHnC9e4l+C/krQYYkENxznhVSDwClIbZVxRw==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.29.3"
|
||||
"@typescript-eslint/types" "4.30.0"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
"@webassemblyjs/ast@1.11.1":
|
||||
|
||||
Reference in new issue
Block a user