Skip to content

Commit

Permalink
Add stub for events to prevent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
englercj committed Dec 24, 2018
1 parent 948e487 commit f98d63e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/Emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,25 @@ export class Emitter
{
for (let i = 0; i < this._treeRoots.length; ++i)
{
this.results.push(this._parseTreeNode(this._treeRoots[i]));
const node = this._parseTreeNode(this._treeRoots[i]);

if (node)
this.results.push(node);
}
}

private _parseTreeNode(node: IDocletTreeNode, parent?: IDocletTreeNode): ts.Node
private _parseTreeNode(node: IDocletTreeNode, parent?: IDocletTreeNode): ts.Node | null
{
const children: ts.Node[] = [];

if (children)
{
for (let i = 0; i < node.children.length; ++i)
{
children.push(this._parseTreeNode(node.children[i], node));
const childNode = this._parseTreeNode(node.children[i], node);

if (childNode)
children.push(childNode);
}
}

Expand Down Expand Up @@ -272,6 +278,10 @@ export class Emitter
case 'typedef':
return createTypedef(node.doclet, children);

case 'event':
// TODO: Handle Events.
return null;

default:
return assertNever(node.doclet);
}
Expand Down
2 changes: 1 addition & 1 deletion src/assert_never.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function assertNever(x: never): never
{
throw new Error("Unexpected object: " + x);
throw new Error("Unexpected object: " + JSON.stringify(x));
}
7 changes: 7 additions & 0 deletions src/typings/jsdoc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ declare interface IDocletBase {
ignore?: boolean;
undocumented?: boolean;
properties?: IDocletProp[];
inherits?: string;
inherited?: boolean;
}

Expand All @@ -101,6 +102,11 @@ declare interface IClassDoclet extends IDocletBase {
classdesc?: string;
}

declare interface IEventDoclet extends IDocletBase {
kind: 'event';
params?: IDocletProp[];
}

declare interface IFunctionDoclet extends IDocletBase {
kind: 'function';
this?: string;
Expand Down Expand Up @@ -140,6 +146,7 @@ declare interface IPackageDoclet {

declare type TDoclet = (
IClassDoclet
| IEventDoclet
| IFunctionDoclet
| IMemberDoclet
| INamespaceDoclet
Expand Down

0 comments on commit f98d63e

Please sign in to comment.