File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,28 @@ func (g *Generator) generateAll() (*TypescriptTypes, error) {
183
183
// type <Name> string
184
184
// These are enums. Store to expand later.
185
185
enums [obj .Name ()] = obj
186
+ case * types.Map :
187
+ // Declared maps that are not structs are still valid codersdk objects.
188
+ // Handle them custom by calling 'typescriptType' directly instead of
189
+ // iterating through each struct field.
190
+ // These types support no json/typescript tags.
191
+ // These are **NOT** enums, as a map in Go would never be used for an enum.
192
+ ts , err := g .typescriptType (obj .Type ().Underlying ())
193
+ if err != nil {
194
+ return nil , xerrors .Errorf ("(map) generate %q: %w" , obj .Name (), err )
195
+ }
196
+
197
+ var str strings.Builder
198
+ _ , _ = str .WriteString (g .posLine (obj ))
199
+ if ts .AboveTypeLine != "" {
200
+ str .WriteString (ts .AboveTypeLine )
201
+ str .WriteRune ('\n' )
202
+ }
203
+ // Use similar output syntax to enums.
204
+ str .WriteString (fmt .Sprintf ("export type %s = %s\n " , obj .Name (), ts .ValueType ))
205
+ structs [obj .Name ()] = str .String ()
206
+ case * types.Array , * types.Slice :
207
+ // TODO: @emyrk if you need this, follow the same design as "*types.Map" case.
186
208
}
187
209
case * types.Var :
188
210
// TODO: Are any enums var declarations? This is also codersdk.Me.
Original file line number Diff line number Diff line change @@ -334,6 +334,9 @@ export interface UserPermissionCheckRequest {
334
334
readonly checks : Record < string , UserPermissionCheck >
335
335
}
336
336
337
+ // From codersdk/users.go:79:6
338
+ export type UserPermissionCheckResponse = Record < string , boolean >
339
+
337
340
// From codersdk/users.go:74:6
338
341
export interface UserRoles {
339
342
readonly roles : string [ ]
You can’t perform that action at this time.
0 commit comments