Print override modifier for parameter property (#11074)
* Install new typescript-estree * Print override modifier for parameter property * Add tests * Add changelog * Fix by Prettier * Update babel-parser * Update snapshot * Update snapshots
This commit is contained in:
1 parent
17d8cb57b7
commit
82687f1c02
7 files changed
+96
-9
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#### Print override modifiers for parameter property (#11074 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
class D extends B {
|
||||
constructor(override foo: string) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
class D extends B {
|
||||
constructor(foo: string) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
class D extends B {
|
||||
constructor(override foo: string) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
+2
-2
@@ -22,10 +22,10 @@
|
||||
"dependencies": {
|
||||
"@angular/compiler": "12.0.4",
|
||||
"@babel/code-frame": "7.14.5",
|
||||
"@babel/parser": "7.14.5",
|
||||
"@babel/parser": "7.14.6",
|
||||
"@glimmer/syntax": "0.79.3",
|
||||
"@iarna/toml": "2.2.5",
|
||||
"@typescript-eslint/typescript-estree": "4.26.1",
|
||||
"@typescript-eslint/typescript-estree": "4.27.0",
|
||||
"angular-estree-parser": "2.4.0",
|
||||
"angular-html-parser": "1.8.0",
|
||||
"camelcase": "6.2.0",
|
||||
|
||||
@@ -190,6 +190,9 @@ function printTypescript(path, options, print) {
|
||||
if (node.static) {
|
||||
parts.push("static ");
|
||||
}
|
||||
if (node.override) {
|
||||
parts.push("override ");
|
||||
}
|
||||
if (node.readonly) {
|
||||
parts.push("readonly ");
|
||||
}
|
||||
|
||||
+6
-6
@@ -441,11 +441,11 @@ class E extends D {
|
||||
`;
|
||||
|
||||
exports[`readonlyInConstructorParameters.ts [babel-ts] format 1`] = `
|
||||
"Unexpected token, expected \\",\\" (7:33)
|
||||
"'public' modifier must precede 'readonly' modifier. (7:26)
|
||||
5 |
|
||||
6 | class E {
|
||||
> 7 | constructor(readonly public x: number) {}
|
||||
| ^
|
||||
| ^
|
||||
8 | }
|
||||
9 |
|
||||
10 | class F {"
|
||||
@@ -489,11 +489,11 @@ new F(1).x;
|
||||
`;
|
||||
|
||||
exports[`readonlyReadonly.ts [babel-ts] format 1`] = `
|
||||
"Unexpected token, expected \\",\\" (3:35)
|
||||
"Duplicate modifier: 'readonly'. (2:14)
|
||||
1 | class C {
|
||||
2 | readonly readonly x: number;
|
||||
> 3 | constructor(readonly readonly y: number) {}
|
||||
| ^
|
||||
> 2 | readonly readonly x: number;
|
||||
| ^
|
||||
3 | constructor(readonly readonly y: number) {}
|
||||
4 | }"
|
||||
`;
|
||||
|
||||
|
||||
@@ -27,3 +27,25 @@ class MyClass extends BaseClass {
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`parameter-property.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
class D extends B {
|
||||
constructor(override foo: string) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
class D extends B {
|
||||
constructor(override foo: string) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,5 @@
|
||||
class D extends B {
|
||||
constructor(override foo: string) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,12 @@
|
||||
chalk "^2.0.0"
|
||||
js-tokens "^4.0.0"
|
||||
|
||||
"@babel/parser@7.14.5", "@babel/parser@^7.1.0", "@babel/parser@^7.14.5", "@babel/parser@^7.7.2":
|
||||
"@babel/parser@7.14.6":
|
||||
version "7.14.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.6.tgz#d85cc68ca3cac84eae384c06f032921f5227f4b2"
|
||||
integrity sha512-oG0ej7efjEXxb4UgE+klVx+3j4MVo+A2vCzm7OUN4CLo6WhQ+vSOD2yJ8m7B+DghObxtLxt3EfgMWpq+AsWehQ==
|
||||
|
||||
"@babel/parser@^7.1.0", "@babel/parser@^7.14.5", "@babel/parser@^7.7.2":
|
||||
version "7.14.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.5.tgz#4cd2f346261061b2518873ffecdf1612cb032829"
|
||||
integrity sha512-TM8C+xtH/9n1qzX+JNHi7AN2zHMTiPUtspO0ZdHflW8KaskkALhMmuMHb4bCmNdv9VAPzJX3/bXqkVLnAvsPfg==
|
||||
@@ -1674,6 +1679,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.26.1.tgz#9e7c523f73c34b04a765e4167ca5650436ef1d38"
|
||||
integrity sha512-STyMPxR3cS+LaNvS8yK15rb8Y0iL0tFXq0uyl6gY45glyI7w0CsyqyEXl/Fa0JlQy+pVANeK3sbwPneCbWE7yg==
|
||||
|
||||
"@typescript-eslint/types@4.27.0":
|
||||
version "4.27.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.27.0.tgz#712b408519ed699baff69086bc59cd2fc13df8d8"
|
||||
integrity sha512-I4ps3SCPFCKclRcvnsVA/7sWzh7naaM/b4pBO2hVxnM3wrU51Lveybdw5WoIktU/V4KfXrTt94V9b065b/0+wA==
|
||||
|
||||
"@typescript-eslint/typescript-estree@4.26.1":
|
||||
version "4.26.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.26.1.tgz#b2ce2e789233d62283fae2c16baabd4f1dbc9633"
|
||||
@@ -1687,6 +1697,19 @@
|
||||
semver "^7.3.5"
|
||||
tsutils "^3.21.0"
|
||||
|
||||
"@typescript-eslint/typescript-estree@4.27.0":
|
||||
version "4.27.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.27.0.tgz#189a7b9f1d0717d5cccdcc17247692dedf7a09da"
|
||||
integrity sha512-KH03GUsUj41sRLLEy2JHstnezgpS5VNhrJouRdmh6yNdQ+yl8w5LrSwBkExM+jWwCJa7Ct2c8yl8NdtNRyQO6g==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.27.0"
|
||||
"@typescript-eslint/visitor-keys" "4.27.0"
|
||||
debug "^4.3.1"
|
||||
globby "^11.0.3"
|
||||
is-glob "^4.0.1"
|
||||
semver "^7.3.5"
|
||||
tsutils "^3.21.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@4.26.1":
|
||||
version "4.26.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.26.1.tgz#0d55ea735cb0d8903b198017d6d4f518fdaac546"
|
||||
@@ -1695,6 +1718,14 @@
|
||||
"@typescript-eslint/types" "4.26.1"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@4.27.0":
|
||||
version "4.27.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.27.0.tgz#f56138b993ec822793e7ebcfac6ffdce0a60cb81"
|
||||
integrity sha512-es0GRYNZp0ieckZ938cEANfEhsfHrzuLrePukLKtY3/KPXcq1Xd555Mno9/GOgXhKzn0QfkDLVgqWO3dGY80bg==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.27.0"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
"@webassemblyjs/ast@1.11.0":
|
||||
version "1.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f"
|
||||
|
||||
Reference in new issue
Block a user