Given that I am performing a TypeScript import, with noTypeDefinitions as a parameter, if I have a package like @types/ramda installed, resolveJSModule will not resolve to ramda.
Instead of gracefully ignoring it, what will instead occur is it will check for the .js file in the wrong directory, and resolveJSModule will throw an exception, rather than nothing (which the || result implies the code expects)
if (namedModule.resolvedModule) {
result = namedModule.resolvedModule.resolvedFileName;
if (namedModule.resolvedModule.extension === '.d.ts' && noTypeDefinitions) {
const resolvedFileNameWithoutExtension = result.replace(namedModule.resolvedModule.extension, '');
result = ts.resolveJSModule(resolvedFileNameWithoutExtension, path.dirname(filename), host) || result;
}
}
For now, I will work around it by enabling type definitions, but I recommend wrapping the logic with a try catch instead of using the or statement, and potentially reworking the logic to check another directory.
There are likely two bugs here:
Given that I am performing a TypeScript import, with
noTypeDefinitions
as a parameter, if I have a package like@types/ramda
installed,resolveJSModule
will not resolve toramda
.Instead of gracefully ignoring it, what will instead occur is it will check for the
.js
file in the wrong directory, andresolveJSModule
will throw an exception, rather than nothing (which the|| result
implies the code expects)For now, I will work around it by enabling type definitions, but I recommend wrapping the logic with a try catch instead of using the or statement, and potentially reworking the logic to check another directory.