Skip to content

Commit

Permalink
Add BROWSER_FEATURESET_YEAR 2025
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 713466756
  • Loading branch information
Closure Team authored and copybara-github committed Jan 9, 2025
1 parent 53c654e commit 326dcb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/com/google/javascript/jscomp/CompilerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ enum BrowserFeaturesetYear {
YEAR_2021(2021, FeatureSet.BROWSER_2021),
YEAR_2022(2022, FeatureSet.BROWSER_2022),
YEAR_2023(2023, FeatureSet.BROWSER_2023),
YEAR_2024(2024, FeatureSet.BROWSER_2024);
YEAR_2024(2024, FeatureSet.BROWSER_2024),
YEAR_2025(2025, FeatureSet.BROWSER_2025);

private final int year;
private final FeatureSet featureSet;
Expand All @@ -160,7 +161,8 @@ enum BrowserFeaturesetYear {
2021, YEAR_2021,
2022, YEAR_2022,
2023, YEAR_2023,
2024, YEAR_2024
2024, YEAR_2024,
2025, YEAR_2025
// go/keep-sorted end
);

Expand All @@ -172,7 +174,7 @@ private BrowserFeaturesetYear(int year, FeatureSet featureSet) {
static BrowserFeaturesetYear from(int year) {
checkState(
YEAR_MAP.containsKey(year),
"Illegal browser_featureset_year=%s. We support values 2012, or 2018..2024 only",
"Illegal browser_featureset_year=%s. We support values 2012, or 2018..2025 only",
year);
return YEAR_MAP.get(year);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@ public final class FeatureSet implements Serializable {
Feature.REGEXP_LOOKBEHIND);

// According to https://compat-table.github.io/compat-table/es2016plus/ this should include all
// features through ES2023.
// features through ES2023. So once LangVersion.ES2023 is added, this should be updated to
// include it.
public static final FeatureSet BROWSER_2024 = ES2021_MODULES;

// According to https://compat-table.github.io/compat-table/es2016plus/ this should include all
// features through ES2024, except for the latest unicode versions for the /v regexp flag, which
// isn't disqualifying. So once LangVersion.ES2024 is added, this should be updated to include it.
public static final FeatureSet BROWSER_2025 = ES2021_MODULES;

public static final FeatureSet ALL = ES_UNSUPPORTED.with(LangVersion.TYPESCRIPT.features());

private enum LangVersion {
Expand Down
3 changes: 3 additions & 0 deletions test/com/google/javascript/jscomp/CompilerOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public void testBrowserFeaturesetYearOptionSetsLanguageOut() {

options.setBrowserFeaturesetYear(2024);
assertThat(options.getOutputFeatureSet()).isEqualTo(FeatureSet.BROWSER_2024);

options.setBrowserFeaturesetYear(2025);
assertThat(options.getOutputFeatureSet()).isEqualTo(FeatureSet.BROWSER_2025);
}

@Test
Expand Down

0 comments on commit 326dcb3

Please sign in to comment.