Skip to content

Commit 8913865

Browse files
committed
Make id field optional in typescript interface
1 parent eb09122 commit 8913865

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/generators/TypescriptInterfaceGenerator.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test("Generate a typescript interface", () => {
5454
5555
export interface Foo {
5656
'@id'?: string;
57-
id: string;
57+
id?: string;
5858
foo: any;
5959
foobar?: FooBar;
6060
readonly bar: string;
@@ -106,7 +106,7 @@ test("Generate a typescript interface without references to other interfaces", (
106106

107107
const res = `export interface Foo {
108108
'@id'?: string;
109-
id: string;
109+
id?: string;
110110
foo: any;
111111
readonly bar: string;
112112
}

templates/typescript/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { {{type}} } from "{{file}}";
66
{{/if}}
77
export interface {{{name}}} {
88
'@id'?: string;
9-
id: string;
9+
id?: string;
1010
{{#each fields}}
1111
{{#if readonly}} readonly{{/if}} {{{name}}}{{#if notrequired}}?{{/if}}: {{{type}}};
1212
{{/each}}

0 commit comments

Comments
 (0)