@@ -830,6 +830,11 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
830
830
// We would need to add more logic to determine this, but for now
831
831
// just hard code them.
832
832
switch n .String () {
833
+ case "github.com/coder/coder/v2/cli/clibase.HostPort" :
834
+ // Custom marshal json to be a string
835
+ return TypescriptType {ValueType : "string" }, nil
836
+ case "github.com/coder/coder/v2/cli/clibase.StringArray" :
837
+ return TypescriptType {ValueType : "string[]" }, nil
833
838
case "github.com/coder/coder/v2/cli/clibase.String" :
834
839
return TypescriptType {ValueType : "string" }, nil
835
840
case "github.com/coder/coder/v2/cli/clibase.YAMLConfigPath" :
@@ -863,6 +868,17 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
863
868
return TypescriptType {ValueType : "string" }, nil
864
869
}
865
870
871
+ // Some hard codes are a bit trickier.
872
+ switch {
873
+ // Struct is a generic, so the type has generic constraints in the string.
874
+ case regexp .MustCompile (`github.com/coder/coder/v2/cli/clibase.Struct\[.*\]` ).MatchString (n .String ()):
875
+ // The marshal json just marshals the underlying value.
876
+ str , ok := ty .Underlying ().(* types.Struct )
877
+ if ok {
878
+ return g .typescriptType (str .Field (0 ).Type ())
879
+ }
880
+ }
881
+
866
882
// Then see if the type is defined elsewhere. If it is, we can just
867
883
// put the objName as it will be defined in the typescript codeblock
868
884
// we generate.
0 commit comments