Skip to content

Commit e2138dc

Browse files
NaridaLaciccarello
authored andcommitted
Fix clodule with subclass (#876)
Fixes #869
1 parent a4669a7 commit e2138dc

File tree

3 files changed

+175
-10
lines changed

3 files changed

+175
-10
lines changed

src/lib/converter/nodes/module.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as ts from 'typescript';
22

3-
import { Reflection, ReflectionKind, ReflectionFlag, ProjectReflection } from '../../models/index';
3+
import { Reflection, ReflectionKind, DeclarationReflection } from '../../models/index';
44
import { createDeclaration } from '../factories/index';
55
import { Context } from '../context';
66
import { Component, ConverterNodeComponent } from '../components';
@@ -22,20 +22,14 @@ export class ModuleConverter extends ConverterNodeComponent<ts.ModuleDeclaration
2222
* @return The resulting reflection or NULL.
2323
*/
2424
convert(context: Context, node: ts.ModuleDeclaration): Reflection | undefined {
25-
const parent = context.scope;
26-
const reflection = createDeclaration(context, node, ReflectionKind.Module);
27-
25+
const reflection = context.isInherit && context.inheritParent === node
26+
? <DeclarationReflection> context.scope
27+
: createDeclaration(context, node, ReflectionKind.Module);
2828
context.withScope(reflection, () => {
29-
if (parent instanceof ProjectReflection && !context.isDeclaration &&
30-
(!module || module.valueOf() === ts.ModuleKind.None.valueOf())) {
31-
reflection!.setFlag(ReflectionFlag.Exported);
32-
}
33-
3429
if (node.body) {
3530
this.owner.convertNode(context, node.body);
3631
}
3732
});
38-
3933
return reflection;
4034
}
4135
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// see https://github.com/TypeStrong/typedoc/issues/869
2+
export class Foo { }
3+
export namespace Foo { // merges with static side of class `Foo`
4+
export const x = 1;
5+
}
6+
7+
export class Bar extends Foo {
8+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
{
2+
"id": 0,
3+
"name": "typedoc",
4+
"kind": 0,
5+
"flags": {},
6+
"children": [
7+
{
8+
"id": 1,
9+
"name": "\"clodule-with-subclass\"",
10+
"kind": 1,
11+
"kindString": "External module",
12+
"flags": {
13+
"isExported": true
14+
},
15+
"originalName": "%BASE%/clodule-with-subclass/clodule-with-subclass.ts",
16+
"children": [
17+
{
18+
"id": 3,
19+
"name": "Bar",
20+
"kind": 128,
21+
"kindString": "Class",
22+
"flags": {
23+
"isExported": true
24+
},
25+
"children": [
26+
{
27+
"id": 4,
28+
"name": "x",
29+
"kind": 1024,
30+
"kindString": "Property",
31+
"flags": {
32+
"isStatic": true,
33+
"isExported": true
34+
},
35+
"sources": [
36+
{
37+
"fileName": "clodule-with-subclass.ts",
38+
"line": 4,
39+
"character": 16
40+
}
41+
],
42+
"type": {
43+
"type": "unknown",
44+
"name": "1"
45+
},
46+
"defaultValue": "1"
47+
}
48+
],
49+
"groups": [
50+
{
51+
"title": "Properties",
52+
"kind": 1024,
53+
"children": [
54+
4
55+
]
56+
}
57+
],
58+
"sources": [
59+
{
60+
"fileName": "clodule-with-subclass.ts",
61+
"line": 7,
62+
"character": 16
63+
}
64+
],
65+
"extendedTypes": [
66+
{
67+
"type": "reference",
68+
"name": "Foo",
69+
"id": 2
70+
}
71+
]
72+
},
73+
{
74+
"id": 2,
75+
"name": "Foo",
76+
"kind": 128,
77+
"kindString": "Class",
78+
"flags": {
79+
"isExported": true
80+
},
81+
"children": [
82+
{
83+
"id": 5,
84+
"name": "x",
85+
"kind": 1024,
86+
"kindString": "Property",
87+
"flags": {
88+
"isStatic": true,
89+
"isExported": true
90+
},
91+
"sources": [
92+
{
93+
"fileName": "clodule-with-subclass.ts",
94+
"line": 4,
95+
"character": 16
96+
}
97+
],
98+
"type": {
99+
"type": "unknown",
100+
"name": "1"
101+
},
102+
"defaultValue": "1"
103+
}
104+
],
105+
"groups": [
106+
{
107+
"title": "Properties",
108+
"kind": 1024,
109+
"children": [
110+
5
111+
]
112+
}
113+
],
114+
"sources": [
115+
{
116+
"fileName": "clodule-with-subclass.ts",
117+
"line": 2,
118+
"character": 16
119+
},
120+
{
121+
"fileName": "clodule-with-subclass.ts",
122+
"line": 3,
123+
"character": 20
124+
}
125+
],
126+
"extendedBy": [
127+
{
128+
"type": "reference",
129+
"name": "Bar",
130+
"id": 3
131+
}
132+
]
133+
}
134+
],
135+
"groups": [
136+
{
137+
"title": "Classes",
138+
"kind": 128,
139+
"children": [
140+
3,
141+
2
142+
]
143+
}
144+
],
145+
"sources": [
146+
{
147+
"fileName": "clodule-with-subclass.ts",
148+
"line": 1,
149+
"character": 0
150+
}
151+
]
152+
}
153+
],
154+
"groups": [
155+
{
156+
"title": "External modules",
157+
"kind": 1,
158+
"children": [
159+
1
160+
]
161+
}
162+
]
163+
}

0 commit comments

Comments
 (0)