Skip to content

Commit 7a91078

Browse files
author
Andy Dill
authored
fix: explicitly specify typeRoots in devtools-frontend (electron#22195)
This is a follow-up to electron#22078, fixing another instance of the same issue
1 parent f965b13 commit 7a91078

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

patches/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55

66
"src/electron/patches/v8": "src/v8",
77

8-
"src/electron/patches/node": "src/third_party/electron_node"
8+
"src/electron/patches/node": "src/third_party/electron_node",
9+
10+
"src/electron/patches/devtools-frontend": "src/third_party/devtools-frontend/src"
911
}

patches/devtools-frontend/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix_explicitly_specify_typeroots.patch
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Andy Dill <andy.dill@gmail.com>
3+
Date: Thu, 13 Feb 2020 20:06:42 -0800
4+
Subject: fix: explicitly specify `typeRoots`
5+
6+
fix: explicitly specify `typeRoots` to avoid crawling parent directories
7+
8+
Upstream CL: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2070561
9+
10+
diff --git a/third_party/typescript/ts_library.py b/third_party/typescript/ts_library.py
11+
index 10f07e63..2ac797d3 100644
12+
--- a/third_party/typescript/ts_library.py
13+
+++ b/third_party/typescript/ts_library.py
14+
@@ -41,6 +41,7 @@ def main():
15+
parser.add_argument('-deps', '--deps', nargs='*', help='List of Ninja build dependencies')
16+
parser.add_argument('-dir', '--front_end_directory', required=True, help='Folder that contains source files')
17+
parser.add_argument('-b', '--tsconfig_output_location', required=True)
18+
+ parser.add_argument('-r', '--tsconfig_type_root', required=True)
19+
opts = parser.parse_args()
20+
with open(ROOT_TS_CONFIG_LOCATION) as root_tsconfig:
21+
try:
22+
@@ -53,6 +54,7 @@ def main():
23+
tsconfig['files'] = [path.join(os.getcwd(), src) for src in opts.sources] + [path.abspath(GLOBAL_DEFS)]
24+
if (opts.deps is not None):
25+
tsconfig['references'] = [{'path': src} for src in opts.deps]
26+
+ tsconfig['compilerOptions']['typeRoots'] = [path.abspath(opts.tsconfig_type_root)]
27+
tsconfig['compilerOptions']['declaration'] = True
28+
tsconfig['compilerOptions']['composite'] = True
29+
tsconfig['compilerOptions']['rootDir'] = path.join(os.getcwd(), opts.front_end_directory)
30+
diff --git a/third_party/typescript/typescript.gni b/third_party/typescript/typescript.gni
31+
index 8a44f0e8..cc6fd295 100644
32+
--- a/third_party/typescript/typescript.gni
33+
+++ b/third_party/typescript/typescript.gni
34+
@@ -40,6 +40,11 @@ template("ts_library") {
35+
"/$target_name-tsconfig.json",
36+
]
37+
38+
+ args += [
39+
+ "--tsconfig_type_root",
40+
+ rebase_path("//third_party/devtools-frontend/src/node_modules/@types"),
41+
+ ]
42+
+
43+
assert(defined(sources), "You must specify TypeScript sources")
44+
45+
args += [ "--sources" ] + rebase_path(sources, root_build_dir)

0 commit comments

Comments
 (0)