Skip to content

Commit dd50d29

Browse files
committed
TS: Fix crash in case of missing type roots
1 parent 4a885cb commit dd50d29

10 files changed

Lines changed: 28 additions & 1 deletion

File tree

javascript/extractor/lib/typescript/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ function handleOpenProjectCommand(command: OpenProjectCommand) {
272272
});
273273

274274
for (let typeRoot of typeRoots || []) {
275-
traverseTypeRoot(typeRoot, "");
275+
if (fs.existsSync(typeRoot) && fs.statSync(typeRoot).isDirectory()) {
276+
traverseTypeRoot(typeRoot, "");
277+
}
276278
}
277279

278280
for (let sourceFile of program.getSourceFiles()) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| tst.ts:0:0:0:0 | tst.ts |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import javascript
2+
3+
from File file
4+
select file
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"include": ["."],
3+
"compilerOptions": {
4+
"typeRoots": ["does-not-exist"]
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x = 5;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| tst.ts:0:0:0:0 | tst.ts |
2+
| typeroot.d.ts:0:0:0:0 | typeroot.d.ts |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import javascript
2+
3+
from File file
4+
select file
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"include": ["."],
3+
"compilerOptions": {
4+
"typeRoots": ["typeroot.d.ts"]
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x = 5;

javascript/ql/test/library-tests/TypeScript/RegressionTests/TypeRootFile/typeroot.d.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)