Skip to content

Commit a5f1536

Browse files
Closure Teamcopybara-github
Closure Team
authored andcommitted
Add BROWSER_FEATURESET_YEAR 2024
PiperOrigin-RevId: 602423649
1 parent 84e5c05 commit a5f1536

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/com/google/javascript/jscomp/CompilerOptions.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,16 @@ private class BrowserFeaturesetYear implements Serializable {
146146

147147
BrowserFeaturesetYear(int year) {
148148
checkState(
149-
year == 2012 || (year >= 2018 && year <= 2023),
150-
"Illegal browser_featureset_year=%s. We support values 2012, or 2018..2023 only",
149+
year == 2012 || (year >= 2018 && year <= 2024),
150+
"Illegal browser_featureset_year=%s. We support values 2012, or 2018..2024 only",
151151
year);
152152
this.year = year;
153153
}
154154

155155
void setDependentValuesFromYear() {
156-
if (year == 2023) {
156+
if (year == 2024) {
157+
setOutputFeatureSet(FeatureSet.BROWSER_2024);
158+
} else if (year == 2023) {
157159
setOutputFeatureSet(FeatureSet.BROWSER_2023);
158160
} else if (year == 2022) {
159161
setOutputFeatureSet(FeatureSet.BROWSER_2022);

src/com/google/javascript/jscomp/parsing/parser/FeatureSet.java

+7
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ 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.
90+
8891
// Set of all fully supported features, even those part of language versions not fully supported
8992
public static final FeatureSet ES_NEXT = ES2021_MODULES.with(LangVersion.ES_NEXT.features());
9093

@@ -128,6 +131,10 @@ public final class FeatureSet implements Serializable {
128131
// we need to change the way that is done to avoid incorrect inclusion of polyfills.
129132
Feature.REGEXP_LOOKBEHIND);
130133

134+
// According to https://compat-table.github.io/compat-table/es2016plus/ this should include all
135+
// features through ES2023.
136+
public static final FeatureSet BROWSER_2024 = ES2021_MODULES;
137+
131138
public static final FeatureSet ALL = ES_UNSUPPORTED.with(LangVersion.TYPESCRIPT.features());
132139

133140
private enum LangVersion {

test/com/google/javascript/jscomp/CompilerOptionsTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public void testBrowserFeaturesetYearOptionSetsLanguageOut() {
5757

5858
options.setBrowserFeaturesetYear(2023);
5959
assertThat(options.getOutputFeatureSet()).isEqualTo(FeatureSet.BROWSER_2023);
60+
61+
options.setBrowserFeaturesetYear(2024);
62+
assertThat(options.getOutputFeatureSet()).isEqualTo(FeatureSet.BROWSER_2024);
6063
}
6164

6265
@Test

0 commit comments

Comments
 (0)