Skip to content

Commit

Permalink
Fix #2476
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Jan 8, 2024
1 parent 972d4f7 commit 7b558b0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

### Bug Fixes

- Fixed an issue where a namespace would not be created for merged function-namespaces only containing types, #2476.

## v0.25.6 (2024-01-01)

### Bug Fixes
Expand Down
6 changes: 3 additions & 3 deletions src/lib/converter/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,7 @@ function convertFunctionOrMethod(
createSignature(scope, ReflectionKind.CallSignature, sig, symbol);
}

convertFunctionProperties(scope, symbol, type);

return ts.SymbolFlags.NamespaceModule;
return convertFunctionProperties(scope, symbol, type);
}

// getDeclaredTypeOfSymbol gets the INSTANCE type
Expand Down Expand Up @@ -1069,6 +1067,8 @@ function convertFunctionProperties(
!hasAnyFlag(symbol.flags, nsFlags))
) {
convertSymbols(context, type.getProperties());

return ts.SymbolFlags.NamespaceModule;
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/test/converter2/issues/gh2476.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare function test(options?: test.Options): void;

declare namespace test {
/** Test options */
interface Options {
a: string;
b: number;
}
}

export { test };
11 changes: 11 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1350,4 +1350,15 @@ describe("Issue Tests", () => {
},
]);
});

it("Creates a separate namespace for `declare namespace` case #2476", () => {
const project = convert();

equal(project.children?.map((c) => [c.name, c.kind]), [
["test", ReflectionKind.Namespace],
["test", ReflectionKind.Function],
]);

equal(project.children[0].children?.map((c) => c.name), ["Options"]);
});
});

0 comments on commit 7b558b0

Please sign in to comment.