Skip to content

Commit 262c989

Browse files
alan-agius4atscott
authored andcommitted
build: update ts_library to produce ES2022 (angular#49332)
This commit patches `ts_library` to be able to produce `ES2022`. Also, updates the build tsconfig and sets `useDefineForClassFields` to `false` to keep the same behaviour of `ng_module`. PR Close angular#49332
1 parent 9c3f8d5 commit 262c989

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

packages/tsconfig-build.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"noFallthroughCasesInSwitch": true,
1717
"moduleResolution": "node",
1818
"module": "esnext",
19-
"target": "es2020",
19+
"target": "es2022",
20+
// Keep the below in sync with ng_module.bzl
21+
"useDefineForClassFields": false,
2022
"lib": ["es2020", "dom"],
2123
"skipLibCheck": true,
2224
// don't auto-discover @types/node, it results in a ///<reference in the .d.ts output

tools/defaults.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def ts_library(
122122
if not package_name:
123123
package_name = _default_module_name(testonly)
124124

125-
default_target = "es2020"
125+
default_target = "es2022"
126126
default_module = "esnext"
127127

128128
_ts_library(
@@ -132,7 +132,7 @@ def ts_library(
132132
deps = deps,
133133
devmode_target = default_target,
134134
devmode_module = default_module,
135-
# For prodmode, the target is set to `ES2020`. `@bazel/typecript` sets `ES2015` by
135+
# For prodmode, the target is set to `ES2022`. `@bazel/typecript` sets `ES2015` by
136136
# default. Note that this should be in sync with the `ng_module` tsconfig generation.
137137
# https://github.com/bazelbuild/rules_nodejs/blob/901df3868e3ceda177d3ed181205e8456a5592ea/third_party/github.com/bazelbuild/rules_typescript/internal/common/tsconfig.bzl#L195
138138
# https://github.com/bazelbuild/rules_nodejs/blob/9b36274dba34204625579463e3da054a9f42cb47/packages/typescript/internal/build_defs.bzl#L85.

tools/postinstall-patches.js

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ ls('node_modules/@types').filter(f => f.startsWith('babel__')).forEach(pkg => {
6565
sed('-i', 'private rootDirsRelative;', 'rootDirsRelative(fileName: string): string;',
6666
'node_modules/@bazel/concatjs/internal/tsc_wrapped/compiler_host.d.ts');
6767

68+
// Add support for ES2022 in ts_library
69+
sed('-i', '"es2020", "esnext"', '"es2020", "es2022", "esnext"',
70+
'node_modules/@bazel/concatjs/internal/build_defs.bzl');
71+
6872
log('\n# patch: delete d.ts files referring to rxjs-compat');
6973
// more info in https://github.com/angular/angular/pull/33786
7074
rm('-rf', [

0 commit comments

Comments
 (0)