diff --git a/.changeset/violet-deer-scream.md b/.changeset/violet-deer-scream.md new file mode 100644 index 0000000..99b0c19 --- /dev/null +++ b/.changeset/violet-deer-scream.md @@ -0,0 +1,5 @@ +--- +'dts-buddy': patch +--- + +fix: don't treat accessors as references diff --git a/src/utils.js b/src/utils.js index 8920b24..17f85e2 100644 --- a/src/utils.js +++ b/src/utils.js @@ -569,6 +569,8 @@ export function is_reference(node, include_declarations = false) { if (ts.isImportTypeNode(node.parent)) return false; if (ts.isPropertySignature(node.parent)) return false; + if (ts.isGetAccessor(node.parent)) return false; + if (ts.isSetAccessor(node.parent)) return false; if (ts.isParameter(node.parent)) return false; if (ts.isMethodDeclaration(node.parent)) return false; if (ts.isLabeledStatement(node.parent)) return false; diff --git a/test/samples/no-renames/input/function.ts b/test/samples/no-renames/input/function.ts new file mode 100644 index 0000000..e64329c --- /dev/null +++ b/test/samples/no-renames/input/function.ts @@ -0,0 +1 @@ +export function bar() {} diff --git a/test/samples/no-renames/input/index.ts b/test/samples/no-renames/input/index.ts index 3a5d7b1..85c7212 100644 --- a/test/samples/no-renames/input/index.ts +++ b/test/samples/no-renames/input/index.ts @@ -2,3 +2,9 @@ export { Y } from './type'; export { Namespace } from './namespace'; export type X = true; export function error(): void {} + +export interface Foo { + get bar(): number; + set bar(x: number); +} +export * from './function'; diff --git a/test/samples/no-renames/output/index.d.ts b/test/samples/no-renames/output/index.d.ts index cba2d3c..81a781e 100644 --- a/test/samples/no-renames/output/index.d.ts +++ b/test/samples/no-renames/output/index.d.ts @@ -1,12 +1,17 @@ declare module 'no-renames' { export type X = true; export function error(): void; + export interface Foo { + get bar(): number; + set bar(x: number); + } export type Y = Namespace.X; export namespace Namespace { interface X { error(): string; } } + export function bar(): void; export {}; } diff --git a/test/samples/no-renames/output/index.d.ts.map b/test/samples/no-renames/output/index.d.ts.map index a4d12a8..e1ac546 100644 --- a/test/samples/no-renames/output/index.d.ts.map +++ b/test/samples/no-renames/output/index.d.ts.map @@ -4,18 +4,22 @@ "names": [ "X", "error", + "Foo", "Y", - "Namespace" + "Namespace", + "bar" ], "sources": [ "../input/index.ts", "../input/type.ts", - "../input/namespace.ts" + "../input/namespace.ts", + "../input/function.ts" ], "sourcesContent": [ + null, null, null, null ], - "mappings": ";aAEYA,CAACA;iBACGC,KAAKA;aCDTC,CAACA;kBCFIC,SAASA" + "mappings": ";aAEYA,CAACA;iBACGC,KAAKA;kBAEJC,GAAGA;;;;aCHRC,CAACA;kBCFIC,SAASA;;;;;iBCAVC,GAAGA" } \ No newline at end of file