@@ -21,6 +21,7 @@ const (
21
21
baseDir = "./codersdk"
22
22
)
23
23
24
+ // TODO: Handle httpapi.Response and other types
24
25
func main () {
25
26
ctx := context .Background ()
26
27
log := slog .Make (sloghuman .Sink (os .Stderr ))
@@ -49,7 +50,6 @@ func (t TypescriptTypes) String() string {
49
50
50
51
for _ , v := range t .Enums {
51
52
s .WriteString (v )
52
- s .WriteRune ('\n' )
53
53
}
54
54
return s .String ()
55
55
}
@@ -168,7 +168,6 @@ func (g *Generator) generateAll() (*TypescriptTypes, error) {
168
168
s .WriteString (fmt .Sprintf ("export type %s = %s\n " ,
169
169
name , strings .Join (values , " | " ),
170
170
))
171
- s .WriteRune ('\n' )
172
171
173
172
enumCodeBlocks [name ] = s .String ()
174
173
}
@@ -290,12 +289,21 @@ func (g *Generator) typescriptType(obj types.Object, ty types.Type) (string, str
290
289
// put the name as it will be defined in the typescript codeblock
291
290
// we generate.
292
291
name := n .Obj ().Name ()
293
- if obj := g .pkg .Types .Scope ().Lookup (n . String ()) ; obj != nil && obj . Name () != name {
292
+ if obj := g .pkg .Types .Scope ().Lookup (name ) ; obj != nil {
294
293
// Sweet! Using other typescript types as fields. This could be an
295
294
// enum or another struct
296
295
return name , "" , nil
297
296
}
298
297
298
+ switch n .String () {
299
+ case "net/url.URL" :
300
+ return "string" , "" , nil
301
+ case "time.Time" :
302
+ return "string" , "is this ok for time?" , nil
303
+ case "github.com/coder/coder/coderd/httpapi.Response" :
304
+
305
+ }
306
+
299
307
// If it's a struct, just use the name of the struct type
300
308
if _ , ok := n .Underlying ().(* types.Struct ); ok {
301
309
return name , "Unknown named type, this might not work" , nil
0 commit comments