Skip to content

Commit b791b1f

Browse files
authored
fix: track dependencies in computed keys of TSMethodSignature (#246)
1 parent 52c1078 commit b791b1f

5 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/fake-js.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ async function collectDependencies(
972972
'ClassProperty',
973973
'TSPropertySignature',
974974
'TSDeclareMethod',
975+
'TSMethodSignature',
975976
])
976977
) {
977978
if (node.computed && isReferenceId(node.key)) {

tests/__snapshots__/index.test.ts.snap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,23 @@ declare const shared1 = "shared1";
399399
export { shared1 as t };"
400400
`;
401401
402+
exports[`method signature 1`] = `
403+
"// index.d.ts
404+
//#region tests/fixtures/method-signature/mod.d.ts
405+
declare const a = "aa";
406+
declare const b = "bb";
407+
declare const c = "cc";
408+
//#endregion
409+
//#region tests/fixtures/method-signature/index.d.ts
410+
interface Test {
411+
[a]: string;
412+
[b](): string;
413+
get [c](): string;
414+
}
415+
//#endregion
416+
export { Test };"
417+
`;
418+
402419
exports[`re-export from lib > both 1`] = `
403420
"// a.d.ts
404421
export * from "stub-lib";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as mod from './mod'
2+
3+
export interface Test {
4+
[mod.a]: string
5+
[mod.b](): string
6+
get [mod.c](): string
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const a = 'aa'
2+
export const b = 'bb'
3+
export const c = 'cc'

tests/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,3 +713,11 @@ test('decorators', async () => {
713713
)
714714
expect(snapshot).toMatchSnapshot()
715715
})
716+
717+
test('method signature', async () => {
718+
const root = path.resolve(dirname, 'fixtures/method-signature')
719+
const { snapshot } = await rolldownBuild(path.resolve(root, 'index.ts'), [
720+
dts({ emitDtsOnly: true }),
721+
])
722+
expect(snapshot).toMatchSnapshot()
723+
})

0 commit comments

Comments
 (0)