Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/analyzer/src/javascript/esutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ export function toMethodParam(

} else if (
babel.isAssignmentPattern(nodeParam) &&
babel.isIdentifier(nodeParam.left) && babel.isLiteral(nodeParam.right)) {
babel.isIdentifier(nodeParam.left)) {
// Parameter with a default: method(param = "default")
name = nodeParam.left.name;
defaultValue = generate(nodeParam.right).code;
Expand Down
23 changes: 22 additions & 1 deletion packages/analyzer/src/test/javascript/class-scanner_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ suite('Class', async () => {
name: 'customInstanceFunction',
description: '',
},
{
name: 'methodWithDefaultParam',
description: '',
params: [{name: 'x', defaultValue: '12'}],
},
{
name: 'methodWithComplexDefaultParam',
description: '',
params: [{name: 'a', defaultValue: '[1, 2, 3]'}],
return: { type: 'void' }
},
{
name: 'customInstanceFunctionWithJSDoc',
description: 'This is the description for ' +
Expand Down Expand Up @@ -514,6 +525,17 @@ suite('Class', async () => {
name: 'customInstanceFunction',
description: '',
},
{
name: 'methodWithDefaultParam',
description: '',
params: [{name: 'x', defaultValue: '12'}],
},
{
name: 'methodWithComplexDefaultParam',
description: '',
params: [{name: 'a', defaultValue: '[1, 2, 3]'}],
return: { type: 'void' }
},
{
name: 'customInstanceFunctionWithJSDoc',
description: 'This is the description for ' +
Expand All @@ -527,7 +549,6 @@ suite('Class', async () => {
name: 'customInstanceFunctionWithParams',
description: '',
params: [{name: 'a'}, {name: 'b'}, {name: 'c'}],

},
{
name: 'customInstanceFunctionWithParamsAndJSDoc',
Expand Down
8 changes: 8 additions & 0 deletions packages/analyzer/src/test/static/class/class-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ class Class {
return 4;
}

methodWithDefaultParam(x = 12) {
return 24;
}

methodWithComplexDefaultParam(a = [1, 2, 3]) {
return;
}

/**
* This is the description for customInstanceFunctionWithJSDoc.
* @return {Number} - The number 5, always.
Expand Down