Skip to content

Commit dd96e67

Browse files
authored
fix: don't treat accessors as references (#105)
get/set on interfaces etc were treated as references, leading to false-positive name deduplications
1 parent 511dbf3 commit dd96e67

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

.changeset/violet-deer-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'dts-buddy': patch
3+
---
4+
5+
fix: don't treat accessors as references

src/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ export function is_reference(node, include_declarations = false) {
569569

570570
if (ts.isImportTypeNode(node.parent)) return false;
571571
if (ts.isPropertySignature(node.parent)) return false;
572+
if (ts.isGetAccessor(node.parent)) return false;
573+
if (ts.isSetAccessor(node.parent)) return false;
572574
if (ts.isParameter(node.parent)) return false;
573575
if (ts.isMethodDeclaration(node.parent)) return false;
574576
if (ts.isLabeledStatement(node.parent)) return false;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export function bar() {}

test/samples/no-renames/input/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ export { Y } from './type';
22
export { Namespace } from './namespace';
33
export type X = true;
44
export function error(): void {}
5+
6+
export interface Foo {
7+
get bar(): number;
8+
set bar(x: number);
9+
}
10+
export * from './function';

test/samples/no-renames/output/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
declare module 'no-renames' {
22
export type X = true;
33
export function error(): void;
4+
export interface Foo {
5+
get bar(): number;
6+
set bar(x: number);
7+
}
48
export type Y = Namespace.X;
59
export namespace Namespace {
610
interface X {
711
error(): string;
812
}
913
}
14+
export function bar(): void;
1015

1116
export {};
1217
}

test/samples/no-renames/output/index.d.ts.map

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44
"names": [
55
"X",
66
"error",
7+
"Foo",
78
"Y",
8-
"Namespace"
9+
"Namespace",
10+
"bar"
911
],
1012
"sources": [
1113
"../input/index.ts",
1214
"../input/type.ts",
13-
"../input/namespace.ts"
15+
"../input/namespace.ts",
16+
"../input/function.ts"
1417
],
1518
"sourcesContent": [
19+
null,
1620
null,
1721
null,
1822
null
1923
],
20-
"mappings": ";aAEYA,CAACA;iBACGC,KAAKA;aCDTC,CAACA;kBCFIC,SAASA"
24+
"mappings": ";aAEYA,CAACA;iBACGC,KAAKA;kBAEJC,GAAGA;;;;aCHRC,CAACA;kBCFIC,SAASA;;;;;iBCAVC,GAAGA"
2125
}

0 commit comments

Comments
 (0)