--- 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 = F extends WidgetFactory? WidgetT : never; export class WidgetConfig { - constructor(readonly widgetClass: WidgetFactory, readonly widgetParams?: Partial) { + constructor(readonly widgetClass: WidgetFactory, readonly widgetParams?: Partial | 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/third_party/typescript/tsgo.gni +++ b/third_party/typescript/tsgo.gni @@ -23,7 +23,7 @@ assert(defined(_platform_dir), "Did not tsgo_inputs = [ "//third_party/typescript/typescript.py", - "//third_party/typescript/$_platform_dir/src/lib/$_binary_name", + "/usr/bin/tsc", ] _tsgo_lib_files = [ @@ -138,5 +138,5 @@ _tsgo_lib_files = [ ] foreach(file, _tsgo_lib_files) { - tsgo_inputs += [ "//third_party/typescript/$_platform_dir/src/lib/$file" ] + tsgo_inputs += [ "//third_party/node/node_modules/typescript/lib/$file" ] } --- 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.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))