JS: Handle .js import of .ts file

This commit is contained in:
Asger F
2019-11-21 21:07:12 +00:00
parent 8f3998915b
commit 82b35a116c
2 changed files with 8 additions and 1 deletions

View File

@@ -83,9 +83,13 @@ abstract class Module extends TopLevel {
result = c.(Folder).getJavaScriptFile("index")
)
or
// handle the case where the import path is missing an extension
// handle the case where the import path is missing the extension
exists(Folder f | f = path.resolveUpTo(path.getNumComponent() - 1) |
result = f.getJavaScriptFile(path.getBaseName())
or
// If a js file was not found look for a file that compiles to js
not exists(f.getJavaScriptFile(path.getBaseName())) and
result = f.getJavaScriptFile(path.getStem())
)
)
}

View File

@@ -205,6 +205,9 @@ abstract class PathExpr extends PathExprBase {
/** Gets the base name of the folder or file this path refers to. */
string getBaseName() { result = getValue().(PathString).getBaseName() }
/** Gets the stem, that is, base name without extension, of the folder or file this path refers to. */
string getStem() { result = getValue().(PathString).getStem() }
/**
* Gets the file or folder that the first `n` components of this path refer to
* when resolved relative to the root folder of the given `priority`.