Skip to content

Commit

Permalink
fix: Declaration merged namespaces sometimes produced multiple reflec…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
Gerrit0 committed Nov 28, 2020
1 parent c702268 commit 5de3bf5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/converter/symbols.ts
Expand Up @@ -101,6 +101,11 @@ export function convertSymbol(
flags = removeFlag(flags, ts.SymbolFlags.SetAccessor);
}

if (hasFlag(symbol.flags, ts.SymbolFlags.NamespaceModule)) {
// This might be here if a namespace is declared several times.
flags = removeFlag(flags, ts.SymbolFlags.ValueModule);
}

for (const flag of getEnumFlags(flags)) {
if (!(flag in symbolConverters)) {
context.logger.verbose(
Expand Down
8 changes: 8 additions & 0 deletions src/test/converter/declaration/namespaces.d.ts
Expand Up @@ -6,3 +6,11 @@ export namespace GH1366 {
// This is only allowed in an ambient context.
export { Foo };
}

export namespace GH1124 {
export type PrimitiveType = boolean | string | number | Date;
}

export namespace GH1124 {
export const Value: string;
}
67 changes: 67 additions & 0 deletions src/test/converter/declaration/specs.json
Expand Up @@ -203,6 +203,72 @@
"kindString": "Module",
"flags": {},
"children": [
{
"id": 19,
"name": "GH1124",
"kind": 2,
"kindString": "Namespace",
"flags": {},
"children": [
{
"id": 20,
"name": "PrimitiveType",
"kind": 4194304,
"kindString": "Type alias",
"flags": {},
"type": {
"type": "union",
"types": [
{
"type": "intrinsic",
"name": "boolean"
},
{
"type": "intrinsic",
"name": "string"
},
{
"type": "intrinsic",
"name": "number"
},
{
"type": "reference",
"name": "Date"
}
]
}
},
{
"id": 21,
"name": "Value",
"kind": 32,
"kindString": "Variable",
"flags": {
"isConst": true
},
"type": {
"type": "intrinsic",
"name": "string"
}
}
],
"groups": [
{
"title": "Type aliases",
"kind": 4194304,
"children": [
20
]
},
{
"title": "Variables",
"kind": 32,
"children": [
21
]
}
]
},
{
"id": 17,
"name": "GH1366",
Expand Down Expand Up @@ -264,6 +330,7 @@
"title": "Namespaces",
"kind": 2,
"children": [
19,
17
]
},
Expand Down

0 comments on commit 5de3bf5

Please sign in to comment.