Skip to content

Commit

Permalink
fix: handle undefined failedLookupLocations (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nthalk committed Apr 24, 2024
1 parent 054c8d3 commit 1a90f66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
10 changes: 10 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 1a90f66

Please sign in to comment.