Skip to content

Commit 7872b85

Browse files
committed
Support default never in Angular v21.2
1 parent 4fde6d8 commit 7872b85

5 files changed

Lines changed: 47 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.16.0",
5757
"acorn-jsx": "5.3.2",
5858
"angular-estree-parser": "15.3.0",
59-
"angular-html-parser": "10.4.0",
59+
"angular-html-parser": "10.5.0",
6060
"camelcase": "9.0.0",
6161
"ci-info": "4.4.0",
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ parsers: ["angular"]
7575
================================================================================
7676
`;
7777

78+
exports[`default-never.html format 1`] = `
79+
====================================options=====================================
80+
parsers: ["angular"]
81+
printWidth: 80 (default) |
82+
=====================================input======================================
83+
@switch ( cond.kind) {
84+
@default never;
85+
}
86+
87+
@switch ( cond.kind) {
88+
@default never ;
89+
}
90+
91+
=====================================output=====================================
92+
@switch (cond.kind) {
93+
@default never;
94+
}
95+
96+
@switch (cond.kind) {
97+
@default never;
98+
}
99+
100+
================================================================================
101+
`;
102+
78103
exports[`defer.html format 1`] = `
79104
====================================options=====================================
80105
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
@@ -3048,10 +3048,10 @@ __metadata:
30483048
languageName: node
30493049
linkType: hard
30503050

3051-
"angular-html-parser@npm:10.4.0":
3052-
version: 10.4.0
3053-
resolution: "angular-html-parser@npm:10.4.0"
3054-
checksum: 10/8c3e290930d59e96a5ca8101787208af81a6e0cfdb127dd432d9ec00e507aeb8445c4bf0055057f5c7da13afd9e78d9339787e7c2b992a0b7a54a2ca4305f0bc
3051+
"angular-html-parser@npm:10.5.0":
3052+
version: 10.5.0
3053+
resolution: "angular-html-parser@npm:10.5.0"
3054+
checksum: 10/8544df535e0b111b44fbf8996141c63a2024f50912b08efaf28c91002260ad8b71af650c10a41aa6e3a0fd8c8f9750f40d4030c39587904aa816e0c88a108727
30553055
languageName: node
30563056
linkType: hard
30573057

@@ -8599,7 +8599,7 @@ __metadata:
85998599
acorn: "npm:8.16.0"
86008600
acorn-jsx: "npm:5.3.2"
86018601
angular-estree-parser: "npm:15.3.0"
8602-
angular-html-parser: "npm:10.4.0"
8602+
angular-html-parser: "npm:10.5.0"
86038603
base64-arraybuffer-es6: "npm:3.1.0"
86048604
browserslist: "npm:4.28.2"
86058605
browserslist-to-esbuild: "npm:2.1.1"

0 commit comments

Comments
 (0)