Skip to content

Commit bf49b63

Browse files
Prevent classes, interfaces and modules from becoming static
1 parent 18e53ee commit bf49b63

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

bin/typedoc.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,6 +3177,14 @@ var td;
31773177
(function (td) {
31783178
var converter;
31793179
(function (converter) {
3180+
/**
3181+
* List of reflection kinds that never should be static.
3182+
*/
3183+
var nonStaticKinds = [
3184+
128 /* Class */,
3185+
256 /* Interface */,
3186+
2 /* Module */
3187+
];
31803188
/**
31813189
* Create a declaration reflection from the given TypeScript node.
31823190
*
@@ -3205,13 +3213,16 @@ var td;
32053213
}
32063214
// Test whether the node is static, when merging a module to a class make the node static
32073215
var isConstructorProperty = false;
3208-
var isStatic = !!(node.flags & 128 /* Static */);
3209-
if (container.kind == 128 /* Class */) {
3210-
if (node.parent && node.parent.kind == 126 /* Constructor */) {
3211-
isConstructorProperty = true;
3212-
}
3213-
else if (!node.parent || node.parent.kind != 185 /* ClassDeclaration */) {
3214-
isStatic = true;
3216+
var isStatic = false;
3217+
if (nonStaticKinds.indexOf(kind) == -1) {
3218+
isStatic = !!(node.flags & 128 /* Static */);
3219+
if (container.kind == 128 /* Class */) {
3220+
if (node.parent && node.parent.kind == 126 /* Constructor */) {
3221+
isConstructorProperty = true;
3222+
}
3223+
else if (!node.parent || node.parent.kind != 185 /* ClassDeclaration */) {
3224+
isStatic = true;
3225+
}
32153226
}
32163227
}
32173228
// Check if we already have a child with the same name and static flag
@@ -8367,17 +8378,17 @@ var td;
83678378
*/
83688379
DefaultTheme.MAPPINGS = [{
83698380
kind: [128 /* Class */],
8370-
isLeaf: true,
8381+
isLeaf: false,
83718382
directory: 'classes',
83728383
template: 'reflection.hbs'
83738384
}, {
83748385
kind: [256 /* Interface */],
8375-
isLeaf: true,
8386+
isLeaf: false,
83768387
directory: 'interfaces',
83778388
template: 'reflection.hbs'
83788389
}, {
83798390
kind: [4 /* Enum */],
8380-
isLeaf: true,
8391+
isLeaf: false,
83818392
directory: 'enums',
83828393
template: 'reflection.hbs'
83838394
}, {

src/td/converter/converters/factories.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
module td.converter
22
{
3+
/**
4+
* List of reflection kinds that never should be static.
5+
*/
6+
var nonStaticKinds = [
7+
models.ReflectionKind.Class,
8+
models.ReflectionKind.Interface,
9+
models.ReflectionKind.Module
10+
];
11+
312
/**
413
* Create a declaration reflection from the given TypeScript node.
514
*
@@ -30,12 +39,15 @@ module td.converter
3039

3140
// Test whether the node is static, when merging a module to a class make the node static
3241
var isConstructorProperty:boolean = false;
33-
var isStatic = !!(node.flags & ts.NodeFlags.Static);
34-
if (container.kind == models.ReflectionKind.Class) {
35-
if (node.parent && node.parent.kind == ts.SyntaxKind.Constructor) {
36-
isConstructorProperty = true;
37-
} else if (!node.parent || node.parent.kind != ts.SyntaxKind.ClassDeclaration) {
38-
isStatic = true;
42+
var isStatic = false;
43+
if (nonStaticKinds.indexOf(kind) == -1) {
44+
isStatic = !!(node.flags & ts.NodeFlags.Static);
45+
if (container.kind == models.ReflectionKind.Class) {
46+
if (node.parent && node.parent.kind == ts.SyntaxKind.Constructor) {
47+
isConstructorProperty = true;
48+
} else if (!node.parent || node.parent.kind != ts.SyntaxKind.ClassDeclaration) {
49+
isStatic = true;
50+
}
3951
}
4052
}
4153

0 commit comments

Comments
 (0)