typescript: introduce devtools_skip_typecheck build flag

This is experimental flag introducing esbuild for typescript transpiler.

I needed to modify some test code to pass tests with esbuild.

Bug: chromium:1278663
DISABLE_THIRD_PARTY_CHECK=need to add esbuild DEPS too
Change-Id: I661951fc4fd8f5e6a2a599e531638ab294f887f2
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3330076
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
diff --git a/scripts/build/ninja/devtools_entrypoint.gni b/scripts/build/ninja/devtools_entrypoint.gni
index 2f24b84..a71c856 100644
--- a/scripts/build/ninja/devtools_entrypoint.gni
+++ b/scripts/build/ninja/devtools_entrypoint.gni
@@ -90,8 +90,6 @@
     _copy_target_name = _entrypoint_target_name + "-copy"
     _rollup_target_name = _entrypoint_target_name + "-rollup"
     _prebundle_target_name = _entrypoint_target_name + "-tsconfig"
-    _generated_declaration_target_name =
-        _entrypoint_target_name + "-generate-declaration"
 
     node_action(_copy_target_name) {
       script = "scripts/build/ninja/copy-file.js"
@@ -146,27 +144,37 @@
       public_deps = [ ":$_prebundle_target_name" ] + invoker.deps
     }
 
-    # TypeScript requires a `module.d.ts` that describes
-    # the public API of the `module.js` entrypoint. To do so, we copy
-    # the generated `prebundle.d.ts` over, as the public API for a
-    # rolled up bundle remains the same.
-    node_action(_generated_declaration_target_name) {
-      script = "scripts/build/ninja/generate-declaration.js"
+    if (!devtools_skip_typecheck) {
+      _generated_declaration_target_name =
+          _entrypoint_target_name + "-generate-declaration"
 
-      args = [
-        rebase_path(target_gen_dir, root_build_dir),
-        invoker.entrypoint,
-      ]
+      # TypeScript requires a `module.d.ts` that describes
+      # the public API of the `module.js` entrypoint. To do so, we copy
+      # the generated `prebundle.d.ts` over, as the public API for a
+      # rolled up bundle remains the same.
+      node_action(_generated_declaration_target_name) {
+        script = "scripts/build/ninja/generate-declaration.js"
 
-      public_deps = [
+        args = [
+          rebase_path(target_gen_dir, root_build_dir),
+          invoker.entrypoint,
+        ]
+
+        public_deps = [
+          ":$_prebundle_target_name",
+          ":$_rollup_target_name",
+        ]
+
+        outputs = [ "$target_gen_dir/$_entrypoint_output_file_name.d.ts" ]
+      }
+
+      _devtools_entrypoint_deps += [ ":$_generated_declaration_target_name" ]
+    } else {
+      _devtools_entrypoint_deps += [
         ":$_prebundle_target_name",
         ":$_rollup_target_name",
       ]
-
-      outputs = [ "$target_gen_dir/$_entrypoint_output_file_name.d.ts" ]
     }
-
-    _devtools_entrypoint_deps += [ ":$_generated_declaration_target_name" ]
   }
 
   # Because we change the filename before rolling up the bundle,
diff --git a/scripts/devtools_paths.py b/scripts/devtools_paths.py
index 2fa6a90..bfa7d17 100644
--- a/scripts/devtools_paths.py
+++ b/scripts/devtools_paths.py
@@ -75,6 +75,10 @@
     return path.join(devtools_root_path(), 'scripts', 'hosted_mode', 'server.js')
 
 
+def esbuild_path():
+    return path.join(devtools_root_path(), 'third_party', 'esbuild', 'esbuild')
+
+
 def downloaded_chrome_binary_path():
     return path.abspath(path.join(
     *{