44 "fmt"
55 "strings"
66
7+ "github.com/buildkite/buildkite-sdk/internal/gen/typescript"
78 "github.com/buildkite/buildkite-sdk/internal/gen/utils"
89)
910
@@ -22,7 +23,7 @@ func (a Array) IsReference() bool {
2223 return a .Reference
2324}
2425
25- func (Array ) IsPrimative () bool {
26+ func (Array ) IsPrimitive () bool {
2627 return false
2728}
2829
@@ -101,23 +102,18 @@ func (a Array) Go() (string, error) {
101102}
102103
103104// TypeScript
104- func (a Array ) TypeScript () (string , error ) {
105- block := utils .NewCodeBlock ()
106-
107- if a .Description != "" {
108- block .AddLines (utils .NewTypeDocComment (a .Description ))
105+ func (a Array ) TypeScript () string {
106+ arrayType := a .Type .TypeScriptInterfaceType ()
107+ if _ , ok := a .Type .(Union ); ok {
108+ arrayType = fmt .Sprintf ("(%s)" , arrayType )
109109 }
110110
111- if union , ok := a .Type .(Union ); ok {
112- block .AddLines (
113- fmt .Sprintf ("export type %s = (%s)[]" , a .Name .ToTitleCase (), union .TypeScriptInterfaceType ()),
114- )
115-
116- return block .String (), nil
117- }
118-
119- block .AddLines (fmt .Sprintf ("export type %s = %s[]" , a .Name .ToTitleCase (), a .Type .TypeScriptInterfaceType ()))
120- return block .String (), nil
111+ typ := typescript .NewType (
112+ a .Name .ToTitleCase (),
113+ a .Description ,
114+ fmt .Sprintf ("%s[]" , arrayType ),
115+ )
116+ return typ .String ()
121117}
122118
123119func (a Array ) TypeScriptInterfaceType () string {
@@ -138,7 +134,7 @@ func (a Array) TypeScriptInterfaceType() string {
138134}
139135
140136func (a Array ) TypeScriptInterfaceKey () string {
141- return a .Name .ToTitleCase ()
137+ return a .Name .Value
142138}
143139
144140// Python
0 commit comments