Skip to content

Commit 3487e88

Browse files
Closure Teamcopybara-github
authored andcommitted
Add BROWSER_FEATURESET_YEAR 2023
PiperOrigin-RevId: 504951035
1 parent 9a58a7f commit 3487e88

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,16 @@ private class BrowserFeaturesetYear implements Serializable {
157157

158158
BrowserFeaturesetYear(int year) {
159159
checkState(
160-
year == 2012 || (year >= 2018 && year <= 2022),
161-
"Illegal browser_featureset_year=%s. We support values 2012, or 2018..2022 only",
160+
year == 2012 || (year >= 2018 && year <= 2023),
161+
"Illegal browser_featureset_year=%s. We support values 2012, or 2018..2023 only",
162162
year);
163163
this.year = year;
164164
}
165165

166166
void setDependentValuesFromYear() {
167-
if (year == 2022) {
167+
if (year == 2023) {
168+
setOutputFeatureSet(FeatureSet.BROWSER_2023);
169+
} else if (year == 2022) {
168170
setOutputFeatureSet(FeatureSet.BROWSER_2022);
169171
} else if (year == 2021) {
170172
setOutputFeatureSet(FeatureSet.BROWSER_2021);
@@ -214,8 +216,7 @@ public void setTypedAstOutputFile(@Nullable Path file) {
214216
this.typedAstOutputFile = file;
215217
}
216218

217-
@Nullable
218-
Path getTypedAstOutputFile() {
219+
@Nullable Path getTypedAstOutputFile() {
219220
return this.typedAstOutputFile;
220221
}
221222

@@ -702,7 +703,6 @@ public boolean shouldRunReplaceMessagesForChrome() {
702703
}
703704
}
704705

705-
706706
/** A CodingConvention to use during the compile. */
707707
private CodingConvention codingConvention;
708708

@@ -1092,7 +1092,7 @@ public boolean shouldProtectHiddenSideEffects() {
10921092
* or side-effected. Gets that can be proven to be pure may still be considered as such.
10931093
*
10941094
* <p>Recall that object-spread is capable of triggering getters. Since the syntax doesn't
1095-
* explicitly specifiy a property, it is essentailly impossible to prove it has no side-effects
1095+
* explicitly specify a property, it is essentailly impossible to prove it has no side-effects
10961096
* without this assumption.
10971097
*/
10981098
private boolean assumeGettersArePure = true;
@@ -1800,7 +1800,7 @@ public void setLanguageOut(LanguageMode languageOut) {
18001800
* Sets the features that allowed to appear in the output. Any feature in the input that is not in
18011801
* this output must be transpiled away.
18021802
*
1803-
* <p>Note: this is an package private API since not every FeatureSet value can be properly output
1803+
* <p>Note: this is a package private API since not every FeatureSet value can be properly output
18041804
* by the compiler without crashing. Both the `setBrowserFeaturesetYear` and `setLanguageOut` APIs
18051805
* are supported alternatives.
18061806
*/
@@ -2275,7 +2275,6 @@ public void setExportTestFunctions(boolean exportTestFunctions) {
22752275
this.exportTestFunctions = exportTestFunctions;
22762276
}
22772277

2278-
22792278
public void setSyntheticBlockStartMarker(String syntheticBlockStartMarker) {
22802279
this.syntheticBlockStartMarker = syntheticBlockStartMarker;
22812280
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,20 @@ public final class FeatureSet implements Serializable {
108108
ES2020_MODULES.without(
109109
// https://kangax.github.io/compat-table/es2016plus/
110110
// Regexp lookbehind is missing in Safari 14.
111-
// IMPORTANT: There is special casing for this feature and the ones excluded for
112-
// BROWSER_2020 above in RewritePolyfills.
113-
// If future Browser FeatureSet Year definitions have to remove any other features, then
114-
// we need to change the way that is done to avoid incorrect inclusion of polyfills.
115111
Feature.REGEXP_LOOKBEHIND);
116112

117113
public static final FeatureSet BROWSER_2022 =
118114
ES2021_MODULES.without(
119115
// https://kangax.github.io/compat-table/es2016plus/
120116
// Regexp lookbehind is still missing in Safari 15.
117+
Feature.REGEXP_LOOKBEHIND);
118+
119+
public static final FeatureSet BROWSER_2023 =
120+
ES2021_MODULES.without(
121+
// https://kangax.github.io/compat-table/es2016plus/
122+
// Regexp lookbehind is still missing in Safari 16.2! It's in Safari TP though so
123+
// 2024 shouldn't need this awkward hack. We can't bump up to ES2022 here because
124+
// Safari 16.2 doesn't support class static blocks.
121125
// IMPORTANT: There is special casing for this feature and the ones excluded for
122126
// BROWSER_2020 above in RewritePolyfills.
123127
// If future Browser FeatureSet Year definitions have to remove any other features, then

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public void testBrowserFeaturesetYearOptionSetsLanguageOut() {
5454

5555
options.setBrowserFeaturesetYear(2022);
5656
assertThat(options.getOutputFeatureSet()).isEqualTo(FeatureSet.BROWSER_2022);
57+
58+
options.setBrowserFeaturesetYear(2023);
59+
assertThat(options.getOutputFeatureSet()).isEqualTo(FeatureSet.BROWSER_2023);
5760
}
5861

5962
@Test

0 commit comments

Comments
 (0)