Angular: Support typeof expression (#16862)

This commit is contained in:
fisker Cheung authored and GitHub committed 2024-11-25 21:39:05 +08:00
1 parent 2c152c9cdb
commit 73efde346a
6 files changed
+126 -6

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
#### Support Angular 19 (#16862 by @fisker)
Angular 19 added [support for `typeof` keyword in template expressions](https://github.com/angular/angular/pull/58183).
<!-- prettier-ignore -->
```html
<!-- Input -->
<div>{{ typeof
x ===
'object' ? 'Y' : 'N'}}</div>
<!-- Prettier stable -->
<div>
{{ typeof
x ===
'object' ? 'Y' : 'N'}}
</div>
// Prettier main
<div>{{ typeof x === "object" ? "Y" : "N" }}</div>
```
+1 -1
View File
@@ -41,7 +41,7 @@
"@typescript-eslint/visitor-keys": "8.15.0",
"acorn": "8.14.0",
"acorn-jsx": "5.3.2",
"angular-estree-parser": "10.1.0",
"angular-estree-parser": "10.2.0",
"angular-html-parser": "7.0.1",
"camelcase": "8.0.0",
"chalk": "5.3.0",
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`typeof-expression.html format 1`] = `
====================================options=====================================
parsers: ["angular"]
printWidth: 80
| printWidth
=====================================input======================================
<div
(click)="
alert(typeof
x)"
on-click="
alert(typeof
x)"
[target]="
typeof
x"
bind-target="
typeof
x"
[(target)]="
typeof
x"
bindon-target="
typeof
x"
*directive="
typeof
x"
>
{{ typeof
x}}
{{ typeof
x ===
'object'}}
{{
!(typeof
x ===
'object')
}}
</div>
=====================================output=====================================
<div
(click)="alert(typeof x)"
on-click="alert(typeof x)"
[target]="typeof x"
bind-target="typeof x"
[(target)]="typeof x"
bindon-target="typeof x"
*directive="typeof x"
>
{{ typeof x }}
{{ typeof x === "object" }}
{{ !(typeof x === "object") }}
</div>
================================================================================
`;
@@ -0,0 +1 @@
runFormatTest(import.meta, ["angular"]);
@@ -0,0 +1,36 @@
<div
(click)="
alert(typeof
x)"
on-click="
alert(typeof
x)"
[target]="
typeof
x"
bind-target="
typeof
x"
[(target)]="
typeof
x"
bindon-target="
typeof
x"
*directive="
typeof
x"
>
{{ typeof
x}}
{{ typeof
x ===
'object'}}
{{
!(typeof
x ===
'object')
}}
</div>
+5 -5
View File
@@ -2173,12 +2173,12 @@ __metadata:
languageName: node
linkType: hard
"angular-estree-parser@npm:10.1.0":
version: 10.1.0
resolution: "angular-estree-parser@npm:10.1.0"
"angular-estree-parser@npm:10.2.0":
version: 10.2.0
resolution: "angular-estree-parser@npm:10.2.0"
peerDependencies:
"@angular/compiler": ^17.3.9 || ^18.0.0 || ^19.0.0
checksum: 10/48b3e6396985b59461d80f5d2a90dc46bf233f04bf7869e5d3b55de4a76ccc82ee040345e0616e91ef09637d307031cb57cc257f5da84ec63b9e54103d734d2c
checksum: 10/1e5a273c99e21e06c177c40cb9a394313296f78d092254b1b46adaa77e244ac7f4241ec67c3e345799e2ab08cab5d78017b73743f57429a4e6d6f6c60ba0a490
languageName: node
linkType: hard
@@ -7264,7 +7264,7 @@ __metadata:
"@typescript-eslint/visitor-keys": "npm:8.15.0"
acorn: "npm:8.14.0"
acorn-jsx: "npm:5.3.2"
angular-estree-parser: "npm:10.1.0"
angular-estree-parser: "npm:10.2.0"
angular-html-parser: "npm:7.0.1"
benchmark: "npm:2.1.4"
browserslist: "npm:4.24.0"