-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve JS files referenced by TypeScript declaration files if possib…
…le (#503) * Add test & fixtures for dts files used with base-url implicit relative scenario * Resolve TypeScript declaration file to matching js files if possible * Include other dts extensions * Add tsconfig file * Fix tests * Format changes --------- Co-authored-by: Lars Kappert <[email protected]>
- Loading branch information
Showing
16 changed files
with
90 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"compilerOptions": {} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/knip/fixtures/dts-baseurl-implicit-relative/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "@fixtures/dts-baseurl-implicit-relative" | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/knip/fixtures/dts-baseurl-implicit-relative/src/dir/subdir/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const h: () => number; | ||
export default h; |
4 changes: 4 additions & 0 deletions
4
packages/knip/fixtures/dts-baseurl-implicit-relative/src/dir/subdir/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const h = () => { | ||
return 1; | ||
}; | ||
export default h; |
5 changes: 5 additions & 0 deletions
5
packages/knip/fixtures/dts-baseurl-implicit-relative/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import h from 'dir/subdir'; | ||
import { g } from 'utils/fn'; | ||
|
||
h; | ||
g; |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/dts-baseurl-implicit-relative/src/utils/fn.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const g: () => void; |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/dts-baseurl-implicit-relative/src/utils/fn.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const g = () => {}; |
5 changes: 5 additions & 0 deletions
5
packages/knip/fixtures/dts-baseurl-implicit-relative/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "src" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import assert from 'node:assert/strict'; | ||
import test from 'node:test'; | ||
import { main } from '../src/index.js'; | ||
import { resolve } from '../src/util/path.js'; | ||
import baseArguments from './helpers/baseArguments.js'; | ||
import baseCounters from './helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('fixtures/dts-baseurl-implicit-relative'); | ||
|
||
test('Include js files referred by the declaration files', async () => { | ||
const { counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
processed: 5, | ||
total: 5, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters