Skip to content

Commit

Permalink
Fix clodule with subclass (#876)
Browse files Browse the repository at this point in the history
Fixes #869
  • Loading branch information
NaridaL authored and aciccarello committed Jan 3, 2019
1 parent a4669a7 commit e2138dc
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/lib/converter/nodes/module.ts
@@ -1,6 +1,6 @@
import * as ts from 'typescript';

import { Reflection, ReflectionKind, ReflectionFlag, ProjectReflection } from '../../models/index';
import { Reflection, ReflectionKind, DeclarationReflection } from '../../models/index';
import { createDeclaration } from '../factories/index';
import { Context } from '../context';
import { Component, ConverterNodeComponent } from '../components';
Expand All @@ -22,20 +22,14 @@ export class ModuleConverter extends ConverterNodeComponent<ts.ModuleDeclaration
* @return The resulting reflection or NULL.
*/
convert(context: Context, node: ts.ModuleDeclaration): Reflection | undefined {
const parent = context.scope;
const reflection = createDeclaration(context, node, ReflectionKind.Module);

const reflection = context.isInherit && context.inheritParent === node
? <DeclarationReflection> context.scope
: createDeclaration(context, node, ReflectionKind.Module);
context.withScope(reflection, () => {
if (parent instanceof ProjectReflection && !context.isDeclaration &&
(!module || module.valueOf() === ts.ModuleKind.None.valueOf())) {
reflection!.setFlag(ReflectionFlag.Exported);
}

if (node.body) {
this.owner.convertNode(context, node.body);
}
});

return reflection;
}
}
@@ -0,0 +1,8 @@
// see https://github.com/TypeStrong/typedoc/issues/869
export class Foo { }
export namespace Foo { // merges with static side of class `Foo`
export const x = 1;
}

export class Bar extends Foo {
}
163 changes: 163 additions & 0 deletions src/test/converter/clodule-with-subclass/specs.json
@@ -0,0 +1,163 @@
{
"id": 0,
"name": "typedoc",
"kind": 0,
"flags": {},
"children": [
{
"id": 1,
"name": "\"clodule-with-subclass\"",
"kind": 1,
"kindString": "External module",
"flags": {
"isExported": true
},
"originalName": "%BASE%/clodule-with-subclass/clodule-with-subclass.ts",
"children": [
{
"id": 3,
"name": "Bar",
"kind": 128,
"kindString": "Class",
"flags": {
"isExported": true
},
"children": [
{
"id": 4,
"name": "x",
"kind": 1024,
"kindString": "Property",
"flags": {
"isStatic": true,
"isExported": true
},
"sources": [
{
"fileName": "clodule-with-subclass.ts",
"line": 4,
"character": 16
}
],
"type": {
"type": "unknown",
"name": "1"
},
"defaultValue": "1"
}
],
"groups": [
{
"title": "Properties",
"kind": 1024,
"children": [
4
]
}
],
"sources": [
{
"fileName": "clodule-with-subclass.ts",
"line": 7,
"character": 16
}
],
"extendedTypes": [
{
"type": "reference",
"name": "Foo",
"id": 2
}
]
},
{
"id": 2,
"name": "Foo",
"kind": 128,
"kindString": "Class",
"flags": {
"isExported": true
},
"children": [
{
"id": 5,
"name": "x",
"kind": 1024,
"kindString": "Property",
"flags": {
"isStatic": true,
"isExported": true
},
"sources": [
{
"fileName": "clodule-with-subclass.ts",
"line": 4,
"character": 16
}
],
"type": {
"type": "unknown",
"name": "1"
},
"defaultValue": "1"
}
],
"groups": [
{
"title": "Properties",
"kind": 1024,
"children": [
5
]
}
],
"sources": [
{
"fileName": "clodule-with-subclass.ts",
"line": 2,
"character": 16
},
{
"fileName": "clodule-with-subclass.ts",
"line": 3,
"character": 20
}
],
"extendedBy": [
{
"type": "reference",
"name": "Bar",
"id": 3
}
]
}
],
"groups": [
{
"title": "Classes",
"kind": 128,
"children": [
3,
2
]
}
],
"sources": [
{
"fileName": "clodule-with-subclass.ts",
"line": 1,
"character": 0
}
]
}
],
"groups": [
{
"title": "External modules",
"kind": 1,
"children": [
1
]
}
]
}

0 comments on commit e2138dc

Please sign in to comment.