Add verify_lib_check to ts_library
Previously, we were gating the `skipLibCheck` on `is_debug=true`.
However, this introduced the problem where CQ runs would fail on
compilation, but local runs succeeding. This confused developers
and required handling a different GN output directory with the GN
flag `is_debug=false`.
But, we don't want to lose the performance benefit related to not
unnecessarily checking all `.d.ts` files all the time. So we have
to find a middleground.
The solution is to add 1 `ts_library` target in `front_end` which
essentially verifies that the `.d.ts` are all in good order. This
means we only do the check once, irrespective the number of
`ts_library` targets in the frontend.
DISABLE_THIRD_PARTY_CHECK=TypeScript fix
[email protected]
[email protected]
Bug: 1011811
Change-Id: Ide2d3a5935fdc34dc79572d65c9e5ce92d78a9a8
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2209090
Reviewed-by: Jack Franklin <[email protected]>
Commit-Queue: Tim van der Lippe <[email protected]>
diff --git a/front_end/BUILD.gn b/front_end/BUILD.gn
index 3b3bb07..25d2e36 100644
--- a/front_end/BUILD.gn
+++ b/front_end/BUILD.gn
@@ -2,10 +2,15 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("../third_party/typescript/typescript.gni")
+
resources_out_dir = "$root_out_dir/resources/inspector"
group("front_end") {
- public_deps = [ ":front_end_html_entrypoints" ]
+ public_deps = [
+ ":front_end_html_entrypoints",
+ ":ts_library-verification",
+ ]
}
copy("front_end_html_entrypoints") {
@@ -21,3 +26,35 @@
outputs = [ "$resources_out_dir/{{source_file_part}}" ]
}
+
+# This target is used to perform checks on all generated `.d.ts` files.
+# Previously we would only run these checks when `is_debug=false`, but
+# this complicated debugging. Therefore, this target now always perform
+# the check, but we only check the `.d.ts` files once (rather than for
+# every single defined `ts_library`).
+#
+# Whenever a folder is fully checked by the TypeScript compiler, add
+# the folder to the `deps` of this target AND add a corresponding
+# `import`-statement to the `verification.ts` file. Without adding
+# the `import`-statement, TypeScript will be "smart" and ignore all
+# declaration files it doesn't have to use.
+ts_library("ts_library-verification") {
+ verify_lib_check = true
+
+ sources = [ "verification.ts" ]
+
+ deps = [
+ "bindings",
+ "browser_sdk",
+ "common",
+ "elements",
+ "formatter_worker",
+ "host",
+ "inspector_overlay",
+ "issues",
+ "protocol_client",
+ "root",
+ "sdk",
+ "workspace",
+ ]
+}