@@ -85,11 +85,16 @@ public final class FeatureSet implements Serializable {
8585
8686 public static final FeatureSet ES2021 = ES2021_MODULES .without (Feature .MODULES );
8787
88- // NOTE: when ES2022 / ES2023 are added, the BROWSER_2024 FeatureSet defined below should be
89- // updated to include them.
88+ public static final FeatureSet ES2022_MODULES =
89+ ES2021_MODULES .with (LangVersion .ES2022 .features ());
90+
91+ public static final FeatureSet ES2022 = ES2022_MODULES .without (Feature .MODULES );
92+
93+ // NOTE: when ES2023 is added, the BROWSER_2024 and BROWSER_2025 FeatureSets defined below should
94+ // be updated to include it.
9095
9196 // Set of all fully supported features, even those part of language versions not fully supported
92- public static final FeatureSet ES_NEXT = ES2021_MODULES .with (LangVersion .ES_NEXT .features ());
97+ public static final FeatureSet ES_NEXT = ES2022_MODULES .with (LangVersion .ES_NEXT .features ());
9398
9499 // Set of features fully supported in checks, even those not fully supported in optimizations
95100 public static final FeatureSet ES_UNSTABLE = ES_NEXT .with (LangVersion .ES_UNSTABLE .features ());
@@ -154,21 +159,23 @@ public final class FeatureSet implements Serializable {
154159 Feature .REGEXP_LOOKBEHIND );
155160
156161 public static final FeatureSet BROWSER_2023 =
157- ES2021_MODULES .without (
162+ ES2022_MODULES .without (
158163 // IMPORTANT: There is special casing for this feature and the ones excluded for
159164 // BROWSER_2020 above in RewritePolyfills.
160165 // If future Browser FeatureSet Year definitions have to remove any other features, then
161166 // we need to change the way that is done to avoid incorrect inclusion of polyfills.
162167 // Chrome 62 (2017). Firefox 78 (2020). Safari 16.4 (2023).
163- Feature .REGEXP_LOOKBEHIND );
168+ Feature .REGEXP_LOOKBEHIND ,
169+ // Chrome 94 (2021). Firefox 93 (2021). Safari 16.4 (2023).
170+ Feature .CLASS_STATIC_BLOCK );
164171
165172 // Note: Only "Hashbang Grammar" is an ES2023 syntax feature. Its versions are:
166173 // Chrome 74 (2019). Firefox 67 (2019). Safari 13.1 (2020).
167- public static final FeatureSet BROWSER_2024 = ES2021_MODULES ;
174+ public static final FeatureSet BROWSER_2024 = ES2022_MODULES ;
168175
169176 // Note: Only "RegExp `v` flag" is an ES2024 syntax feature. Its versions are:
170177 // Chrome 112 (2023). Firefox 116 (2023). Safari 17 (2023).
171- public static final FeatureSet BROWSER_2025 = ES2021_MODULES ;
178+ public static final FeatureSet BROWSER_2025 = ES2022_MODULES ;
172179
173180 public static final FeatureSet ALL = ES_UNSUPPORTED .with (LangVersion .TYPESCRIPT .features ());
174181
@@ -182,6 +189,7 @@ private enum LangVersion {
182189 ES2019 ,
183190 ES2020 ,
184191 ES2021 ,
192+ ES2022 ,
185193 ES_NEXT ,
186194 ES_UNSTABLE ,
187195 ES_UNSUPPORTED ,
@@ -292,9 +300,15 @@ public enum Feature {
292300 NUMERIC_SEPARATOR ("numeric separator" , LangVersion .ES2021 ),
293301 LOGICAL_ASSIGNMENT ("Logical assignments" , LangVersion .ES2021 ),
294302
303+ // ES 2022 adds https://github.com/tc39/proposal-class-fields
304+ PUBLIC_CLASS_FIELDS ("Public class fields" , LangVersion .ES2022 ),
305+
306+ // ES 2022 adds https://github.com/tc39/proposal-class-static-block
307+ CLASS_STATIC_BLOCK ("Class static block" , LangVersion .ES2022 ),
308+
295309 // ES 2022 adds https://github.com/tc39/proposal-regexp-match-indices
296310 // Note: Untranspilable.
297- REGEXP_FLAG_D ("RegExp flag 'd'" , LangVersion .ES_NEXT ),
311+ REGEXP_FLAG_D ("RegExp flag 'd'" , LangVersion .ES2022 ),
298312
299313 // ES_NEXT: Features that are fully supported, but part of a language version that is not yet
300314 // fully supported
@@ -311,11 +325,6 @@ public enum Feature {
311325 // incorrectly prune those polyfills.
312326 ES_UNSTABLE_RUNTIME ("es_unstable runtime" , LangVersion .ES_UNSTABLE ),
313327
314- PUBLIC_CLASS_FIELDS ("Public class fields" , LangVersion .ES_NEXT ), // Part of ES2022
315-
316- // ES 2022 adds https://github.com/tc39/proposal-class-static-block
317- CLASS_STATIC_BLOCK ("Class static block" , LangVersion .ES_UNSTABLE ),
318-
319328 // ES_UNSUPPORTED: Features that we can parse, but not yet supported in all checks
320329
321330 // ES 2022 adds https://github.com/tc39/proposal-class-fields
@@ -377,6 +386,9 @@ public String version() {
377386 if (ES2021_MODULES .contains (this )) {
378387 return "es_2021" ;
379388 }
389+ if (ES2022_MODULES .contains (this )) {
390+ return "es_2022" ;
391+ }
380392 if (ES_NEXT .contains (this )) {
381393 return "es_next" ;
382394 }
@@ -530,6 +542,7 @@ public static FeatureSet valueOf(String name) {
530542 case "es_2019" -> ES2019 ;
531543 case "es_2020" -> ES2020 ;
532544 case "es_2021" -> ES2021 ;
545+ case "es_2022" -> ES2022 ;
533546 case "es_next" -> ES_NEXT ;
534547 case "es_unstable" -> ES_UNSTABLE ;
535548 case "es_unsupported" -> ES_UNSUPPORTED ;
0 commit comments