fix: explicitly specify typeRoots in devtools-frontend (#22195)

This is a follow-up to #22078, fixing another instance of the same issue
This commit is contained in:
Andy Dill 2020-02-24 14:09:11 -08:00 committed by GitHub
parent f965b13d74
commit 7a91078cc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 1 deletions

View file

@ -5,5 +5,7 @@
"src/electron/patches/v8": "src/v8",
"src/electron/patches/node": "src/third_party/electron_node"
"src/electron/patches/node": "src/third_party/electron_node",
"src/electron/patches/devtools-frontend": "src/third_party/devtools-frontend/src"
}

View file

@ -0,0 +1 @@
fix_explicitly_specify_typeroots.patch

View file

@ -0,0 +1,45 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andy Dill <andy.dill@gmail.com>
Date: Thu, 13 Feb 2020 20:06:42 -0800
Subject: fix: explicitly specify `typeRoots`
fix: explicitly specify `typeRoots` to avoid crawling parent directories
Upstream CL: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2070561
diff --git a/third_party/typescript/ts_library.py b/third_party/typescript/ts_library.py
index 10f07e63..2ac797d3 100644
--- a/third_party/typescript/ts_library.py
+++ b/third_party/typescript/ts_library.py
@@ -41,6 +41,7 @@ def main():
parser.add_argument('-deps', '--deps', nargs='*', help='List of Ninja build dependencies')
parser.add_argument('-dir', '--front_end_directory', required=True, help='Folder that contains source files')
parser.add_argument('-b', '--tsconfig_output_location', required=True)
+ parser.add_argument('-r', '--tsconfig_type_root', required=True)
opts = parser.parse_args()
with open(ROOT_TS_CONFIG_LOCATION) as root_tsconfig:
try:
@@ -53,6 +54,7 @@ def main():
tsconfig['files'] = [path.join(os.getcwd(), src) for src in opts.sources] + [path.abspath(GLOBAL_DEFS)]
if (opts.deps is not None):
tsconfig['references'] = [{'path': src} for src in opts.deps]
+ tsconfig['compilerOptions']['typeRoots'] = [path.abspath(opts.tsconfig_type_root)]
tsconfig['compilerOptions']['declaration'] = True
tsconfig['compilerOptions']['composite'] = True
tsconfig['compilerOptions']['rootDir'] = path.join(os.getcwd(), opts.front_end_directory)
diff --git a/third_party/typescript/typescript.gni b/third_party/typescript/typescript.gni
index 8a44f0e8..cc6fd295 100644
--- a/third_party/typescript/typescript.gni
+++ b/third_party/typescript/typescript.gni
@@ -40,6 +40,11 @@ template("ts_library") {
"/$target_name-tsconfig.json",
]
+ args += [
+ "--tsconfig_type_root",
+ rebase_path("//third_party/devtools-frontend/src/node_modules/@types"),
+ ]
+
assert(defined(sources), "You must specify TypeScript sources")
args += [ "--sources" ] + rebase_path(sources, root_build_dir)