@@ -32,10 +32,9 @@ func main() {
3232 // Serpent has some types referenced in the codersdk.
3333 // We want the referenced types generated.
3434 referencePackages := map [string ]string {
35- "github.com/coder/preview" : "" ,
36- "github.com/coder/serpent" : "Serpent" ,
37- "github.com/hashicorp/hcl/v2" : "Hcl" ,
38- "tailscale.com/derp" : "" ,
35+ "github.com/coder/preview/types" : "Preview" ,
36+ "github.com/coder/serpent" : "Serpent" ,
37+ "tailscale.com/derp" : "" ,
3938 // Conflicting name "DERPRegion"
4039 "tailscale.com/tailcfg" : "Tail" ,
4140 "tailscale.com/net/netcheck" : "Netcheck" ,
@@ -90,8 +89,22 @@ func TypeMappings(gen *guts.GoParser) error {
9089 gen .IncludeCustomDeclaration (map [string ]guts.TypeOverride {
9190 "github.com/coder/coder/v2/codersdk.NullTime" : config .OverrideNullable (config .OverrideLiteral (bindings .KeywordString )),
9291 // opt.Bool can return 'null' if unset
93- "tailscale.com/types/opt.Bool" : config .OverrideNullable (config .OverrideLiteral (bindings .KeywordBoolean )),
94- "github.com/hashicorp/hcl/v2.Expression" : config .OverrideLiteral (bindings .KeywordUnknown ),
92+ "tailscale.com/types/opt.Bool" : config .OverrideNullable (config .OverrideLiteral (bindings .KeywordBoolean )),
93+ // hcl diagnostics should be cast to `preview.FriendlyDiagnostic`
94+ "github.com/hashicorp/hcl/v2.Diagnostic" : func () bindings.ExpressionType {
95+ return bindings .Reference (bindings.Identifier {
96+ Name : "FriendlyDiagnostic" ,
97+ Package : nil ,
98+ Prefix : "" ,
99+ })
100+ },
101+ "github.com/coder/preview/types.HCLString" : func () bindings.ExpressionType {
102+ return bindings .Reference (bindings.Identifier {
103+ Name : "NullHCLString" ,
104+ Package : nil ,
105+ Prefix : "" ,
106+ })
107+ },
95108 })
96109
97110 err := gen .IncludeCustom (map [string ]string {
0 commit comments