diff --git a/index.js b/index.js index 9d0ccb9..c12de44 100644 --- a/index.js +++ b/index.js @@ -260,7 +260,7 @@ function tsLookup({ dependency, filename, directory, webpackConfig, tsConfig, ts } } else { const suffix = '.d.ts'; - const lookUpLocations = namedModule.failedLookupLocations + const lookUpLocations = (namedModule.failedLookupLocations ?? []) .filter(string => string.endsWith(suffix)) .map(string => string.substr(0, string.length - suffix.length)); diff --git a/test/test.js b/test/test.js index 6bca2b5..bc43259 100644 --- a/test/test.js +++ b/test/test.js @@ -398,6 +398,16 @@ describe('filing-cabinet', () => { assert.equal(result, expected); }); + it('finds imports of non-existent typescript imports', () => { + const filename = path.join(directory, '/index.ts'); + const result = cabinet({ + partial: 'virtual:test-virtual', + filename, + directory + }); + assert.equal(result, ''); + }); + it('finds imports of non-typescript files using custom import paths', () => { const filename = path.join(directory, '/index.ts'); const result = cabinet({