fix(typings): include static members

Fixes #3175

Closes #3780
This commit is contained in:
Alex Eagle 2015-08-21 15:02:30 -07:00 committed by Alex Eagle
parent bf4b75ee9c
commit 894af28529
3 changed files with 15 additions and 4 deletions

View File

@ -10,7 +10,7 @@
{%- macro memberInfo(member) -%}
{$ commentBlock(member, 5) $}
{$ member.name $}{% if member.optional %}?{% endif -%}
{% if member.isStatic -%}static {% endif -%}{$ member.name $}{% if member.optional %}?{% endif -%}
{% if member.typeParameters %}<{% for typeParam in member.typeParameters %}{$ typeParam $}{% if not loop.last %}, {% endif %}{% endfor %}>{% endif -%}
{%- if member.parameters -%}({% for param in member.parameters %}{$ param $}{% if not loop.last %}, {% endif %}{% endfor %}){%- endif -%}
{%- if member.returnType -%}
@ -58,6 +58,9 @@ declare module {$ module.namespace $} {
{%- if export.callMember %}
{$ memberInfo(export.callMember) $}
{% endif -%}
{%- for static in export.statics %}
{$ memberInfo(static) $}
{%- endfor -%}
{%- for member in export.members %}
{$ memberInfo(member) $}
{%- endfor %}

View File

@ -64,6 +64,7 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
log.debug('>>>> EXPORT: ' + exportDoc.name + ' (' + exportDoc.docType + ') from ' + moduleDoc.id);
exportDoc.members = [];
exportDoc.statics = [];
// Generate docs for each of the export's members
if (resolvedExport.flags & ts.SymbolFlags.HasMembers) {
@ -102,6 +103,16 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
docs.push(memberDoc);
exportDoc.members.push(memberDoc);
}
} else if (resolvedExport.flags & ts.SymbolFlags.HasExports) {
for (var exported in resolvedExport.exports) {
if (exported === 'prototype') continue;
if (hidePrivateMembers && exported.charAt(0) === '_') continue;
var memberSymbol = resolvedExport.exports[exported];
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker);
memberDoc.isStatic = true;
docs.push(memberDoc);
exportDoc.statics.push(memberDoc);
}
}
if (sortClassMembers) {

View File

@ -16,9 +16,6 @@ export {TypeLiteral} from './type_literal';
* injector to index in arrays rather than looking up items in maps.
*/
export class Key {
/**
* @private
*/
constructor(public token: Object, public id: number) {
if (isBlank(token)) {
throw new BaseException('Token must be defined!');