WebUI: Remove "incremental" flag from default tsconfig_base.json.

The incremental flag is causing issues where stale output is picked up
by the build, leading to flaky tests when switching between branches or
when bots switch between patches.

Under the cover, with incremental builds TS generates a .tsbuildinfo
file that holds metadata (hashes) about the input files. When switching
between git branches (or patches) the build can get into a state where
TS compiler looks at the .tsbuildinfo file and sees that none of the
source files have changed.

For example performing the following sequence, with specially crafted
branches, can cause a bad build:

1) Switch to branchA -> build
   .tsbuildinfo info is generated
2) Switch to branchB -> build
   .tsbuildinfo is ignored, but remains in the gen/ folder, other
   generated files modified/deleted
3) Switch to branchA -> build
   .tsbuildinfo from #1 causes the TS Compiler to not re-generate
   its output.

TS compiler doesn't check whether the output files have been modified
or even deleted, leaving the build with either stale or missing files
respectively.

Removing the |incremental| flag fixes the issue, and TS compiler always
re-generates its output, whenever GN decides that the ts_library()
target is dirty, which correctly takes into account whether output files
have been modified or deleted.

Bug: 1229303
Fixed: 1229235
Change-Id: I17a1297f3283bb4ad592aec78927b10cfa74d395
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3032602
Auto-Submit: dpapad <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#902216}
diff --git a/tools/typescript/ts_library.gni b/tools/typescript/ts_library.gni
index e29fb803..84fc32c 100644
--- a/tools/typescript/ts_library.gni
+++ b/tools/typescript/ts_library.gni
@@ -17,10 +17,7 @@
                            ])
 
     inputs = [ "//tools/typescript/tsconfig_base.json" ]
-    outputs = [
-      "$target_gen_dir/tsconfig.json",
-      "$target_gen_dir/tsconfig.tsbuildinfo",
-    ]
+    outputs = [ "$target_gen_dir/tsconfig.json" ]
 
     assert(defined(in_files) || defined(invoker.definitions))
 
@@ -39,6 +36,10 @@
       composite = invoker.composite
     }
 
+    if (composite) {
+      outputs += [ "$target_gen_dir/tsconfig.tsbuildinfo" ]
+    }
+
     if (defined(in_files)) {
       outputs += [ "$target_gen_dir/tsconfig.manifest" ]
       foreach(_source, in_files) {
diff --git a/tools/typescript/ts_library.py b/tools/typescript/ts_library.py
index f4069cf..a05d279 100644
--- a/tools/typescript/ts_library.py
+++ b/tools/typescript/ts_library.py
@@ -51,13 +51,13 @@
       else os.path.relpath(TSCONFIG_BASE_PATH, args.gen_dir)
 
   tsconfig['compilerOptions'] = collections.OrderedDict()
-  tsconfig['compilerOptions']['tsBuildInfoFile'] = 'tsconfig.tsbuildinfo'
   tsconfig['compilerOptions']['rootDir'] = root_dir
   tsconfig['compilerOptions']['outDir'] = out_dir
 
   if args.composite:
     tsconfig['compilerOptions']['composite'] = True
     tsconfig['compilerOptions']['declaration'] = True
+    tsconfig['compilerOptions']['tsBuildInfoFile'] = 'tsconfig.tsbuildinfo'
 
   tsconfig['files'] = []
   if args.in_files is not None:
diff --git a/tools/typescript/ts_library_test.py b/tools/typescript/ts_library_test.py
index c564c4b..65dc09fd 100755
--- a/tools/typescript/ts_library_test.py
+++ b/tools/typescript/ts_library_test.py
@@ -98,13 +98,16 @@
         'bar.js',
         'tsconfig.json',
         'tsconfig.manifest',
-        'tsconfig.tsbuildinfo',
     ]
     for f in files:
       self.assertTrue(os.path.exists(os.path.join(gen_dir, f)), f)
 
-    dts_file = 'bar.d.ts'
-    self.assertFalse(os.path.exists(os.path.join(gen_dir, dts_file)), dts_file)
+    non_existing_files = [
+        'bar.d.ts',
+        'tsconfig.tsbuildinfo',
+    ]
+    for f in non_existing_files:
+      self.assertFalse(os.path.exists(os.path.join(gen_dir, f)), f)
 
   # Builds project3, which includes only definition files.
   def _build_project3(self):
diff --git a/tools/typescript/tsconfig_base.json b/tools/typescript/tsconfig_base.json
index cba0a73..17bb7cb 100644
--- a/tools/typescript/tsconfig_base.json
+++ b/tools/typescript/tsconfig_base.json
@@ -6,8 +6,6 @@
     "noEmitOnError": true,
     "pretty": true,
 
-    "incremental": true,
-
     "forceConsistentCasingInFileNames": true,
     "noFallthroughCasesInSwitch": true,
     "noImplicitReturns": true,