Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion examples/basic/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,9 @@ export function createSomething() {
*
* Taken from http://usejsdoc.org/tags-inline-link.html.
*/
export function functionWithDocLink():void { }
export function functionWithDocLink():void { }

/**
* A function with a destructuring argument that implements interface.
*/
export function functionWithTypedDestr({name}: classes.INameInterface) { }
7 changes: 6 additions & 1 deletion src/lib/converter/types/binding-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ export class BindingObjectConverter extends ConverterTypeComponent implements Ty
*
* @param context The context object describing the current state the converter is in.
* @param node The binding pattern that should be converted.
* @param type The type of the node if already known.
* @returns The type reflection representing the given binding pattern.
*/
convertNode(context: Context, node: ts.BindingPattern): Type {
convertNode(context: Context, node: ts.BindingPattern, type: ts.Type): Type {
const declaration = new DeclarationReflection();
declaration.kind = ReflectionKind.TypeLiteral;
declaration.name = '__type';
declaration.parent = context.scope;

if (type) {
declaration.type = context.converter.convertType(context, null, type);
}

context.registerReflection(declaration, null);
context.trigger(Converter.EVENT_CREATE_DECLARATION, declaration, node);
context.withScope(declaration, () => {
Expand Down
9 changes: 9 additions & 0 deletions src/test/converter/destructuring/destructuring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ const [destructArrayWithIgnoresA, , ...destructArrayWithIgnoresRest] = [1, 2, 3,
* Destructuring function parameters.
*/
function drawText({text = "", location:[x, y] = [0, 0], bold = false}) { }

interface ForDestructuring {
param: number;
}

/**
* Typed destructuring function parameters.
*/
function typedDestructuring({param = 1}: ForDestructuring) { }
Loading