1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
--- a/third_party/devtools-frontend/src/front_end/core/host/DispatchHttpRequestClient.ts
+++ b/third_party/devtools-frontend/src/front_end/core/host/DispatchHttpRequestClient.ts
@@ -14,7 +14,7 @@ export enum ErrorType {
}
export class DispatchHttpRequestError extends Error {
- constructor(readonly type: ErrorType, readonly response?: DispatchHttpRequestResult, options?: ErrorOptions) {
+ constructor(readonly type: ErrorType, readonly response?: DispatchHttpRequestResult | undefined, options?: ErrorOptions) {
super(undefined, options);
}
}
--- a/third_party/devtools-frontend/src/front_end/ui/legacy/ARIAUtils.ts
+++ b/third_party/devtools-frontend/src/front_end/ui/legacy/ARIAUtils.ts
@@ -420,7 +420,7 @@ export class LiveAnnouncer {
element.textContent = Platform.StringUtilities.trimEndWithMaxLength(announcedMessage, 10000);
}
- static getOrCreateAnnouncerElement(container: HTMLElement = document.body, role: AnnouncerRole, opts?: {
+ static getOrCreateAnnouncerElement(container: undefined | HTMLElement = document.body, role: AnnouncerRole, opts?: {
force: boolean,
}): HTMLElement {
const existingAnnouncerElement = LiveAnnouncer.#announcerElementsByRole[role].get(container);
--- a/third_party/devtools-frontend/src/front_end/ui/legacy/Widget.ts
+++ b/third_party/devtools-frontend/src/front_end/ui/legacy/Widget.ts
@@ -84,7 +84,7 @@ export type WidgetFactory<WidgetT extend
export type InferWidgetTFromFactory<F> = F extends WidgetFactory<infer WidgetT>? WidgetT : never;
export class WidgetConfig<WidgetT extends AnyWidget> {
- constructor(readonly widgetClass: WidgetFactory<WidgetT>, readonly widgetParams?: Partial<WidgetT>) {
+ constructor(readonly widgetClass: WidgetFactory<WidgetT>, readonly widgetParams?: Partial<WidgetT> | undefined) {
}
}
--- a/third_party/devtools-frontend/src/scripts/build/typescript/typescript_vars.gni
+++ b/third_party/devtools-frontend/src/scripts/build/typescript/typescript_vars.gni
@@ -6,7 +6,7 @@ import("//build/toolchain/rbe.gni")
import("../ninja/vars.gni")
if (host_os == "linux") {
- tsc_binary = "//third_party/typescript/linux-amd64/src/lib/tsc"
+ tsc_binary = "/usr/bin/tsc"
} else if (host_os == "win") {
tsc_binary = "//third_party/typescript/windows-amd64/src/lib/tsc.exe"
} else if (host_os == "mac") {
--- a/third_party/devtools-frontend/src/third_party/typescript/typescript.py
+++ b/third_party/devtools-frontend/src/third_party/typescript/typescript.py
@@ -10,6 +10,7 @@ import os
def GetBinaryPath():
+ return "/usr/bin/tsc"
if platform.machine() == 'arm64':
darwin_path = 'mac-arm64'
else:
--- a/ui/webui/webui_features.gni
+++ b/ui/webui/webui_features.gni
@@ -33,7 +33,7 @@ declare_args() {
# Enable the native TypeScript compiler (tsgo) instead of the JS-based one.
# TODO(crbug.com/423789047): Remove this flag once fully committed to v7.
- use_typescript_go = true
+ use_typescript_go = false
}
if (enable_cast_receiver || is_cast_android || is_castos) {
--- a/tools/typescript/ts_definitions.gni
+++ b/tools/typescript/ts_definitions.gni
@@ -3,7 +3,11 @@
# found in the LICENSE file.
import("//third_party/node/node.gni")
-import("//third_party/typescript/tsgo.gni")
+import("//ui/webui/webui_features.gni")
+
+if (use_typescript_go) {
+ import("//third_party/typescript/tsgo.gni")
+}
assert(is_chromeos)
@@ -20,9 +24,12 @@ template("ts_definitions") {
])
inputs = [
- "//package.json",
- "//tools/typescript/tsconfig_definitions_base.json",
- ] + tsgo_inputs
+ "//package.json",
+ "//tools/typescript/tsconfig_definitions_base.json",
+ ]
+ if (use_typescript_go) {
+ inputs += tsgo_inputs
+ }
outputs = [ "$target_gen_dir/tsconfig_definitions.json" ]
root_dir = "."
@@ -52,6 +59,10 @@ template("ts_definitions") {
"--js_files",
] + js_files
+ if (use_typescript_go) {
+ args += [ "--use_typescript_go" ]
+ }
+
if (defined(deps)) {
args += [ "--deps" ]
--- a/tools/typescript/ts_definitions.py
+++ b/tools/typescript/ts_definitions.py
@@ -13,8 +13,9 @@ _CWD = os.getcwd()
_HERE_DIR = os.path.dirname(__file__)
_SRC_DIR = os.path.normpath(os.path.join(_HERE_DIR, '..', '..'))
-sys.path.append(os.path.join(_SRC_DIR, 'third_party', 'typescript'))
-import typescript
+sys.path.append(os.path.join(_SRC_DIR, 'third_party', 'node'))
+import node
+import node_modules
_TSCONFIG_BASE = 'tsconfig_definitions_base.json'
@@ -40,6 +41,7 @@ def main(argv):
parser.add_argument('--root_dir', required=True)
parser.add_argument('--js_files', nargs='*', required=True)
parser.add_argument('--path_mappings', nargs='*')
+ parser.add_argument('--use_typescript_go', action='store_true')
args = parser.parse_args(argv)
with open(
@@ -81,9 +83,22 @@ def main(argv):
if os.path.exists(to_delete):
os.remove(to_delete)
- stdout = typescript.RunTypeScript(
- ['--project', os.path.join(args.gen_dir, _TSCONFIG_GEN)]
- )
+ stdout = None
+ if args.use_typescript_go:
+ sys.path.append(os.path.join(_SRC_DIR, 'third_party', 'typescript'))
+ import typescript
+
+ stdout = typescript.RunTypeScript(
+ ['--project', os.path.join(args.gen_dir, _TSCONFIG_GEN)]
+ )
+ else:
+ stdout = node.RunNode(
+ [
+ node_modules.PathToTypescript(),
+ '--project',
+ os.path.join(args.gen_dir, _TSCONFIG_GEN),
+ ]
+ )
# Verify that that no unexpected .d.ts files were generated.
lines = stdout.splitlines()
--- a/tools/typescript/ts_library.gni
+++ b/tools/typescript/ts_library.gni
@@ -3,7 +3,11 @@
# found in the LICENSE file.
import("//third_party/node/node.gni")
-import("//third_party/typescript/tsgo.gni")
+import("//ui/webui/webui_features.gni")
+
+if (use_typescript_go) {
+ import("//third_party/typescript/tsgo.gni")
+}
template("ts_library") {
node(target_name) {
@@ -21,11 +25,14 @@ template("ts_library") {
])
inputs = [
- "//package.json",
- "//tools/typescript/path_utils.py",
- "//tools/typescript/tsconfig_base.json",
- "//tools/typescript/validate_tsconfig.py",
- ] + tsgo_inputs
+ "//package.json",
+ "//tools/typescript/path_utils.py",
+ "//tools/typescript/tsconfig_base.json",
+ "//tools/typescript/validate_tsconfig.py",
+ ]
+ if (use_typescript_go) {
+ inputs += tsgo_inputs
+ }
outputs = [ "$target_gen_dir/tsconfig_$target_name.json" ]
@@ -77,6 +84,10 @@ template("ts_library") {
target_name,
]
+ if (use_typescript_go) {
+ args += [ "--use_typescript_go" ]
+ }
+
if (defined(in_files)) {
args += [ "--in_files" ] + in_files
}
--- a/tools/typescript/ts_library.py
+++ b/tools/typescript/ts_library.py
@@ -15,8 +15,9 @@ _CWD = os.getcwd()
_HERE_DIR = os.path.dirname(__file__)
_SRC_DIR = os.path.normpath(os.path.join(_HERE_DIR, '..', '..'))
-sys.path.append(os.path.join(_SRC_DIR, 'third_party', 'typescript'))
-import typescript
+sys.path.append(os.path.join(_SRC_DIR, 'third_party', 'node'))
+import node
+import node_modules
from path_utils import isInAshFolder, getTargetPath
from validate_tsconfig import (
@@ -70,6 +71,7 @@ def main(argv):
)
parser.add_argument('--enable_source_maps', action='store_true')
parser.add_argument('--output_suffix', required=True)
+ parser.add_argument('--use_typescript_go', action='store_true')
args = parser.parse_args(argv)
root_dir = os.path.relpath(args.root_dir, args.gen_dir)
@@ -305,9 +307,21 @@ def main(argv):
os.remove(to_check)
try:
- typescript.RunTypeScript(
- ['--project', os.path.join(args.gen_dir, tsconfig_file)]
- )
+ if args.use_typescript_go:
+ sys.path.append(os.path.join(_SRC_DIR, 'third_party', 'typescript'))
+ import typescript
+
+ typescript.RunTypeScript(
+ ['--project', os.path.join(args.gen_dir, tsconfig_file)]
+ )
+ else:
+ node.RunNode(
+ [
+ node_modules.PathToTypescript(),
+ '--project',
+ os.path.join(args.gen_dir, tsconfig_file),
+ ]
+ )
finally:
if args.composite:
# `.tsbuildinfo` is generated by TypeScript for incremenetal compilation
@@ -327,13 +341,24 @@ def main(argv):
# Invoke the TS compiler again, with the --listFilesOnly flag, to detect any
# files that are used by the build, but not properly declared as dependencies.
- out = typescript.RunTypeScript(
- [
- '--project',
- os.path.join(args.gen_dir, tsconfig_file),
- '--listFilesOnly',
- ]
- )
+ out = None
+ if args.use_typescript_go:
+ out = typescript.RunTypeScript(
+ [
+ '--project',
+ os.path.join(args.gen_dir, tsconfig_file),
+ '--listFilesOnly',
+ ]
+ )
+ else:
+ out = node.RunNode(
+ [
+ node_modules.PathToTypescript(),
+ '--project',
+ os.path.join(args.gen_dir, tsconfig_file),
+ '--listFilesOnly',
+ ]
+ )
files_list = out.split('\n')
definitions_files = list(filter(lambda f: f.endswith('.d.ts'), files_list))
|