diff --git a/changelog_unreleased/typescript/10945.md b/changelog_unreleased/typescript/10945.md new file mode 100644 index 000000000000..f7ac515acf0e --- /dev/null +++ b/changelog_unreleased/typescript/10945.md @@ -0,0 +1,26 @@ +#### Support TypeScript 4.3 (#10945 by @sosukesuzuki) + +##### [`override` modifiers in class elements](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3-rc/#override-and-the-noimplicitoverride-flag) + +```ts +class Foo extends { + override method() {} +} +``` + +##### [static index signatures (`[key: KeyType]: ValueType`) in classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3-rc/#static-index-signatures) + +```ts +class Foo { + static [key: string]: Bar; +} +``` + +##### [`get` / `set` in type declarations](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3-rc/#separate-write-types-on-properties) + +```ts +interface Foo { + set foo(value); + get foo(): string; +} +``` diff --git a/package.json b/package.json index b185c756c00e..a59506c2bcfc 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@babel/parser": "7.14.3", "@glimmer/syntax": "0.79.2", "@iarna/toml": "2.2.5", - "@typescript-eslint/typescript-estree": "4.24.0", + "@typescript-eslint/typescript-estree": "4.25.0", "angular-estree-parser": "2.3.0", "angular-html-parser": "1.8.0", "camelcase": "6.2.0", @@ -79,7 +79,7 @@ "semver": "7.3.5", "string-width": "4.2.2", "strip-ansi": "6.0.0", - "typescript": "4.2.4", + "typescript": "4.3.1-rc", "unicode-regex": "3.0.0", "unified": "9.2.1", "vnopts": "1.0.2", diff --git a/tests/format/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap b/tests/format/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap index ecaec1d3d738..45f2edd1376c 100644 --- a/tests/format/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/typescript-babel-only/__snapshots__/jsfmt.spec.js.snap @@ -60,68 +60,6 @@ class Bar { ================================================================================ `; -exports[`ts-4.3-override-modifier.ts format 1`] = ` -====================================options===================================== -parsers: ["babel-ts"] -printWidth: 80 - | printWidth -=====================================input====================================== -class MyClass extends BaseClass { - override show() {} - public override show() {} - override size = 5; - override readonly size = 5; -} - -=====================================output===================================== -class MyClass extends BaseClass { - override show() {} - public override show() {} - override size = 5; - override readonly size = 5; -} - -================================================================================ -`; - -exports[`ts4.3-type-members-get-set.ts format 1`] = ` -====================================options===================================== -parsers: ["babel-ts"] -printWidth: 80 - | printWidth -=====================================input====================================== -interface Foo { - get foo(): string; - set bar(v); -} - -type Foo = { - get foo(): string; - set bar(v); -} - -interface Foo { - set bar(foo: string); -} - -=====================================output===================================== -interface Foo { - get foo(): string; - set bar(v); -} - -type Foo = { - get foo(): string; - set bar(v); -}; - -interface Foo { - set bar(foo: string); -} - -================================================================================ -`; - exports[`tuple-labeled-ts.ts format 1`] = ` ====================================options===================================== parsers: ["babel-ts"] diff --git a/tests/format/typescript/override-modifiers/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/override-modifiers/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000000..5352d1ceae7f --- /dev/null +++ b/tests/format/typescript/override-modifiers/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`override-modifier.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +class MyClass extends BaseClass { + override show() {} + public override show() {} + override size = 5; + override readonly size = 5; +} + +=====================================output===================================== +class MyClass extends BaseClass { + override show() {} + public override show() {} + override size = 5; + override readonly size = 5; +} + +================================================================================ +`; diff --git a/tests/format/typescript/override-modifiers/jsfmt.spec.js b/tests/format/typescript/override-modifiers/jsfmt.spec.js new file mode 100644 index 000000000000..2ea3bb6eb2e4 --- /dev/null +++ b/tests/format/typescript/override-modifiers/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["typescript"]); diff --git a/tests/format/misc/typescript-babel-only/ts-4.3-override-modifier.ts b/tests/format/typescript/override-modifiers/override-modifier.ts similarity index 100% rename from tests/format/misc/typescript-babel-only/ts-4.3-override-modifier.ts rename to tests/format/typescript/override-modifiers/override-modifier.ts diff --git a/tests/format/typescript/type-member-get-set/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/type-member-get-set/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000000..f034192f4269 --- /dev/null +++ b/tests/format/typescript/type-member-get-set/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-member-get-set.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +interface Foo { + get foo(): string; + set bar(v); +} + +type Foo = { + get foo(): string; + set bar(v); +} + +interface Foo { + set bar(foo: string); +} + +=====================================output===================================== +interface Foo { + get foo(): string; + set bar(v); +} + +type Foo = { + get foo(): string; + set bar(v); +}; + +interface Foo { + set bar(foo: string); +} + +================================================================================ +`; diff --git a/tests/format/typescript/type-member-get-set/jsfmt.spec.js b/tests/format/typescript/type-member-get-set/jsfmt.spec.js new file mode 100644 index 000000000000..2ea3bb6eb2e4 --- /dev/null +++ b/tests/format/typescript/type-member-get-set/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["typescript"]); diff --git a/tests/format/misc/typescript-babel-only/ts4.3-type-members-get-set.ts b/tests/format/typescript/type-member-get-set/type-member-get-set.ts similarity index 100% rename from tests/format/misc/typescript-babel-only/ts4.3-type-members-get-set.ts rename to tests/format/typescript/type-member-get-set/type-member-get-set.ts diff --git a/yarn.lock b/yarn.lock index 7a7a177eecf5..ee8d65fa1a7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1660,10 +1660,10 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.19.0.tgz#5181d5d2afd02e5b8f149ebb37ffc8bd7b07a568" integrity sha512-A4iAlexVvd4IBsSTNxdvdepW0D4uR/fwxDrKUa+iEY9UWvGREu2ZyB8ylTENM1SH8F7bVC9ac9+si3LWNxcBuA== -"@typescript-eslint/types@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.24.0.tgz#6d0cca2048cbda4e265e0c4db9c2a62aaad8228c" - integrity sha512-tkZUBgDQKdvfs8L47LaqxojKDE+mIUmOzdz7r+u+U54l3GDkTpEbQ1Jp3cNqqAU9vMUCBA1fitsIhm7yN0vx9Q== +"@typescript-eslint/types@4.25.0": + version "4.25.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.25.0.tgz#0e444a5c5e3c22d7ffa5e16e0e60510b3de5af87" + integrity sha512-+CNINNvl00OkW6wEsi32wU5MhHti2J25TJsJJqgQmJu3B3dYDBcmOxcE5w9cgoM13TrdE/5ND2HoEnBohasxRQ== "@typescript-eslint/typescript-estree@4.19.0": version "4.19.0" @@ -1678,13 +1678,13 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/typescript-estree@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.24.0.tgz#b49249679a98014d8b03e8d4b70864b950e3c90f" - integrity sha512-kBDitL/by/HK7g8CYLT7aKpAwlR8doshfWz8d71j97n5kUa5caHWvY0RvEUEanL/EqBJoANev8Xc/mQ6LLwXGA== +"@typescript-eslint/typescript-estree@4.25.0": + version "4.25.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.25.0.tgz#942e4e25888736bff5b360d9b0b61e013d0cfa25" + integrity sha512-1B8U07TGNAFMxZbSpF6jqiDs1cVGO0izVkf18Q/SPcUAc9LhHxzvSowXDTvkHMWUVuPpagupaW63gB6ahTXVlg== dependencies: - "@typescript-eslint/types" "4.24.0" - "@typescript-eslint/visitor-keys" "4.24.0" + "@typescript-eslint/types" "4.25.0" + "@typescript-eslint/visitor-keys" "4.25.0" debug "^4.1.1" globby "^11.0.1" is-glob "^4.0.1" @@ -1699,12 +1699,12 @@ "@typescript-eslint/types" "4.19.0" eslint-visitor-keys "^2.0.0" -"@typescript-eslint/visitor-keys@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.24.0.tgz#a8fafdc76cad4e04a681a945fbbac4e35e98e297" - integrity sha512-4ox1sjmGHIxjEDBnMCtWFFhErXtKA1Ec0sBpuz0fqf3P+g3JFGyTxxbF06byw0FRsPnnbq44cKivH7Ks1/0s6g== +"@typescript-eslint/visitor-keys@4.25.0": + version "4.25.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.25.0.tgz#863e7ed23da4287c5b469b13223255d0fde6aaa7" + integrity sha512-AmkqV9dDJVKP/TcZrbf6s6i1zYXt5Hl8qOLrRDTFfRNae4+LB8A4N3i+FLZPW85zIxRy39BgeWOfMS3HoH5ngg== dependencies: - "@typescript-eslint/types" "4.24.0" + "@typescript-eslint/types" "4.25.0" eslint-visitor-keys "^2.0.0" "@webassemblyjs/ast@1.11.0": @@ -3129,6 +3129,7 @@ eslint-plugin-jest@24.3.6: "eslint-plugin-prettier-internal-rules@link:scripts/tools/eslint-plugin-prettier-internal-rules": version "0.0.0" + uid "" eslint-plugin-react@7.23.2: version "7.23.2" @@ -6941,10 +6942,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@4.2.4: - version "4.2.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961" - integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg== +typescript@4.3.1-rc: + version "4.3.1-rc" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.1-rc.tgz#925149c8d8514e20a6bd8d4bd7f42adac67ab59c" + integrity sha512-L3uJ0gcntaRaKni9aV2amYB+pCDVodKe/B5+IREyvtKGsDOF7cYjchHb/B894skqkgD52ykRuWatIZMqEsHIqA== unherit@^1.0.4: version "1.1.3"