Skip to content

Commit

Permalink
implement nullable properties for interface
Browse files Browse the repository at this point in the history
  • Loading branch information
marioke committed Mar 17, 2023
1 parent 1794550 commit 9432382
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-code-generator",
"version": "0.0.8",
"version": "0.0.9",
"description": "",
"scripts": {
"build": "tsc",
Expand Down
5 changes: 5 additions & 0 deletions src/InterfaceBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export class InterfaceBuilder extends BuilderBase {
builder.append(`${this.getIndent(1)} * ${property.comment}`);
builder.append(`${this.getIndent(1)} */`);
}
if (property.nullable) {
builder.append(`${this.getIndent(1)}${property.name}?: ${property.type};`);
return;
}
builder.append(`${this.getIndent(1)}${property.name}: ${property.type};`);
});
builder.append("}");
Expand All @@ -102,4 +106,5 @@ export interface InterfaceProperty {
name: string;
type: string;
comment?: string;
nullable?: boolean;
}

0 comments on commit 9432382

Please sign in to comment.