Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Fix display of default value in output #146

Merged
merged 2 commits into from
Jul 23, 2024
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Unreleased

- Result object scoring name changed to distance [#143](https://github.com/hypermodeAI/functions-as/pull/143)
- Collect default values for optional parameters instead of rewriting with supplied_params [#144](https://github.com/hypermodeAI/functions-as/pull/144)
- Collect default values for optional parameters instead of rewriting with supplied_params [#144](https://github.com/hypermodeAI/functions-as/pull/144) [#146](https://github.com/hypermodeAI/functions-as/pull/146)

## 2024-07-16 - Version 0.10.3

Expand Down
4 changes: 3 additions & 1 deletion src/transform/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export class FunctionSignature {
const param = this.parameters[i]!;
const defaultValue = param.default;
params += `${param.name}: ${param.type.name}`;
if (defaultValue) params += ` = ${defaultValue}`;
if (defaultValue !== undefined) {
params += ` = ${JSON.stringify(defaultValue)}`;
}
params += ", ";
}
return `${this.name}(${params.endsWith(", ") ? params.slice(0, params.length - 2) : params}): ${this.returnType.name}`;
Expand Down