Skip to content

Commit 7b558b0

Browse files
committed
Fix #2476
1 parent 972d4f7 commit 7b558b0

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
### Bug Fixes
4+
5+
- Fixed an issue where a namespace would not be created for merged function-namespaces only containing types, #2476.
6+
37
## v0.25.6 (2024-01-01)
48

59
### Bug Fixes

src/lib/converter/symbols.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,7 @@ function convertFunctionOrMethod(
484484
createSignature(scope, ReflectionKind.CallSignature, sig, symbol);
485485
}
486486

487-
convertFunctionProperties(scope, symbol, type);
488-
489-
return ts.SymbolFlags.NamespaceModule;
487+
return convertFunctionProperties(scope, symbol, type);
490488
}
491489

492490
// getDeclaredTypeOfSymbol gets the INSTANCE type
@@ -1069,6 +1067,8 @@ function convertFunctionProperties(
10691067
!hasAnyFlag(symbol.flags, nsFlags))
10701068
) {
10711069
convertSymbols(context, type.getProperties());
1070+
1071+
return ts.SymbolFlags.NamespaceModule;
10721072
}
10731073
}
10741074

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
declare function test(options?: test.Options): void;
2+
3+
declare namespace test {
4+
/** Test options */
5+
interface Options {
6+
a: string;
7+
b: number;
8+
}
9+
}
10+
11+
export { test };

src/test/issues.c2.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,4 +1350,15 @@ describe("Issue Tests", () => {
13501350
},
13511351
]);
13521352
});
1353+
1354+
it("Creates a separate namespace for `declare namespace` case #2476", () => {
1355+
const project = convert();
1356+
1357+
equal(project.children?.map((c) => [c.name, c.kind]), [
1358+
["test", ReflectionKind.Namespace],
1359+
["test", ReflectionKind.Function],
1360+
]);
1361+
1362+
equal(project.children[0].children?.map((c) => c.name), ["Options"]);
1363+
});
13531364
});

0 commit comments

Comments
 (0)