Skip to content

Commit 881360b

Browse files
committed
Support default never in Angular v21.2 (#19034)
1 parent 07d6724 commit 881360b

5 files changed

Lines changed: 48 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"acorn": "8.15.0",
5757
"acorn-jsx": "5.3.2",
5858
"angular-estree-parser": "15.3.0",
59-
"angular-html-parser": "10.3.0",
59+
"angular-html-parser": "10.5.0",
6060
"camelcase": "9.0.0",
6161
"ci-info": "4.3.1",
6262
"cjk-regex": "3.4.0",

src/language-html/print/angular-control-flow-block.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ function printAngularControlFlowBlock(path, options, print) {
2020

2121
docs.push("@", node.name);
2222

23+
if (isSwitchExhaustiveCheck(node)) {
24+
docs.push(";");
25+
return docs;
26+
}
27+
2328
if (node.parameters) {
2429
docs.push(" (", group(print("parameters")), ")");
2530
}
@@ -53,6 +58,10 @@ function shouldCloseBlock(node) {
5358
const isSwitchCaseBlock = (node) =>
5459
node?.kind === "angularControlFlowBlock" &&
5560
(node.name === "case" || node.name === "default");
61+
62+
const isSwitchExhaustiveCheck = (node) =>
63+
node?.kind === "angularControlFlowBlock" && node.name === "default never";
64+
5665
// https://github.com/angular/angular/commit/0ad3adc7c6d4094f1e3432a3f2e3bdc9862cb4fa#diff-77a6f285c6ea13d6644ef635e7495e71134d1141af2650cb9ae5631ff1f38bf2R263
5766
// https://github.com/prettier/prettier/issues/18563#issuecomment-3728354491
5867
function isSwitchFallthroughCase(node) {

tests/format/angular/control-flow/__snapshots__/format.test.js.snap

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,32 @@ printWidth: 80
7777
================================================================================
7878
`;
7979

80+
exports[`default-never.html format 1`] = `
81+
====================================options=====================================
82+
parsers: ["angular"]
83+
printWidth: 80
84+
| printWidth
85+
=====================================input======================================
86+
@switch ( cond.kind) {
87+
@default never;
88+
}
89+
90+
@switch ( cond.kind) {
91+
@default never ;
92+
}
93+
94+
=====================================output=====================================
95+
@switch (cond.kind) {
96+
@default never;
97+
}
98+
99+
@switch (cond.kind) {
100+
@default never;
101+
}
102+
103+
================================================================================
104+
`;
105+
80106
exports[`defer.html format 1`] = `
81107
====================================options=====================================
82108
parsers: ["angular"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@switch ( cond.kind) {
2+
@default never;
3+
}
4+
5+
@switch ( cond.kind) {
6+
@default never ;
7+
}

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,10 +2861,10 @@ __metadata:
28612861
languageName: node
28622862
linkType: hard
28632863

2864-
"angular-html-parser@npm:10.3.0":
2865-
version: 10.3.0
2866-
resolution: "angular-html-parser@npm:10.3.0"
2867-
checksum: 10/97078879db8f53fc9645d2cd8c748c9eb3770790ec96f249bd96e0ab9293f65506b7facd201c17f2f18884e82550f3c362972e7b3a5448b0e1fb2a6938e9ef4d
2864+
"angular-html-parser@npm:10.5.0":
2865+
version: 10.5.0
2866+
resolution: "angular-html-parser@npm:10.5.0"
2867+
checksum: 10/8544df535e0b111b44fbf8996141c63a2024f50912b08efaf28c91002260ad8b71af650c10a41aa6e3a0fd8c8f9750f40d4030c39587904aa816e0c88a108727
28682868
languageName: node
28692869
linkType: hard
28702870

@@ -7518,7 +7518,7 @@ __metadata:
75187518
acorn: "npm:8.15.0"
75197519
acorn-jsx: "npm:5.3.2"
75207520
angular-estree-parser: "npm:15.3.0"
7521-
angular-html-parser: "npm:10.3.0"
7521+
angular-html-parser: "npm:10.5.0"
75227522
base64-arraybuffer-es6: "npm:3.1.0"
75237523
browserslist: "npm:4.28.0"
75247524
browserslist-to-esbuild: "npm:2.1.1"

0 commit comments

Comments
 (0)