mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
TS: Fix a crash when allowJs: true was set
This commit is contained in:
@@ -578,6 +578,11 @@ public class AutoBuild {
|
||||
for (File sourceFile : project.getSourceFiles()) {
|
||||
Path sourcePath = sourceFile.toPath();
|
||||
if (!files.contains(normalizePath(sourcePath))) continue;
|
||||
if (!FileType.TYPESCRIPT.getExtensions().contains(FileUtil.extension(sourcePath))) {
|
||||
// For the time being, skip non-TypeScript files, even if the TypeScript
|
||||
// compiler can parse them for us.
|
||||
continue;
|
||||
}
|
||||
if (!extractedFiles.contains(sourcePath)) {
|
||||
typeScriptFiles.add(sourcePath.toFile());
|
||||
}
|
||||
|
||||
@@ -147,7 +147,8 @@ public class Main {
|
||||
List<File> filesToExtract = new ArrayList<>();
|
||||
for (File sourceFile : project.getSourceFiles()) {
|
||||
if (files.contains(normalizeFile(sourceFile))
|
||||
&& !extractedFiles.contains(sourceFile.getAbsoluteFile())) {
|
||||
&& !extractedFiles.contains(sourceFile.getAbsoluteFile())
|
||||
&& FileType.TYPESCRIPT.getExtensions().contains(FileUtil.extension(sourceFile))) {
|
||||
filesToExtract.add(sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
import f = require("./tst");
|
||||
f("world");
|
||||
@@ -0,0 +1,5 @@
|
||||
| main.ts:1:8:1:8 | f | (x: string) => string |
|
||||
| main.ts:1:20:1:26 | "./tst" | any |
|
||||
| main.ts:2:1:2:1 | f | (x: string) => string |
|
||||
| main.ts:2:1:2:10 | f("world") | string |
|
||||
| main.ts:2:3:2:9 | "world" | "world" |
|
||||
@@ -0,0 +1,4 @@
|
||||
import javascript
|
||||
|
||||
from Expr e
|
||||
select e, e.getType()
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true
|
||||
},
|
||||
"include": ["."]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @param {String} x
|
||||
*/
|
||||
module.exports = function(x) {
|
||||
return 'Hello ' + x;
|
||||
}
|
||||
Reference in New Issue
Block a user