`failedLookupLocations` no longer exists in Typescript
odinho opened this issue · 1 comments
odinho commented
I needed to get newer versions of ts-parsers etc to support using the using
keyword. Got some issues with filing-cabinet
then which is a sub-sub dependency of madge
.
The stacktrace:
TypeError: Cannot read properties of undefined (reading 'filter')
❯ tsLookup node_modules/filing-cabinet/index.js:262:8
❯ module.exports node_modules/filing-cabinet/index.js:73:18
❯ Function.module.exports._getDependencies node_modules/dependency-tree/index.js:100:20
❯ traverse node_modules/dependency-tree/index.js:146:37
❯ traverse node_modules/dependency-tree/index.js:170:29
❯ traverse node_modules/dependency-tree/index.js:170:29
❯ module.exports node_modules/dependency-tree/index.js:37:19
❯ node_modules/madge/lib/tree.js:121:27
❯ Tree.generateTree node_modules/madge/lib/tree.js:116:9
I've done a local yarn patch filing-cabinet
which looks like this to fix it:
diff --git a/index.js b/index.js
index d5e792434fb0b3ad5ef060cc9b924b845df5605d..4e257fd48b898b08275abd79db66c1a8c4546f9f 100644
--- a/index.js
+++ b/index.js
@@ -259,10 +259,10 @@ function tsLookup({ dependency, filename, directory, webpackConfig, tsConfig, ts
} else {
const suffix = '.d.ts';
const lookUpLocations = namedModule.failedLookupLocations
- .filter(string => string.endsWith(suffix))
+ ?.filter(string => string.endsWith(suffix))
.map(string => string.substr(0, string.length - suffix.length));
- result = lookUpLocations.find(location => ts.sys.fileExists(location)) || '';
+ result = lookUpLocations?.find(location => ts.sys.fileExists(location)) || '';
}
if (!result && tsConfigPath && compilerOptions.baseUrl && compilerOptions.paths) {
Which works well and as expected. Not sure about the impact of effectively just ignoring that code though, but thought I'd give a heads up. Also if anyone else is (or comes into) the same situation.
I can provide the above patch as a PR of course, but I'm quite sure that it's probably not a great route. So someone with more insight should probably look at it :)
XhmikosR commented
Feel free to submit a PR with a test case