@@ -32,10 +32,9 @@ func main() {
32
32
// Serpent has some types referenced in the codersdk.
33
33
// We want the referenced types generated.
34
34
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" :"" ,
39
38
// Conflicting name "DERPRegion"
40
39
"tailscale.com/tailcfg" :"Tail" ,
41
40
"tailscale.com/net/netcheck" :"Netcheck" ,
@@ -90,8 +89,22 @@ func TypeMappings(gen *guts.GoParser) error {
90
89
gen .IncludeCustomDeclaration (map [string ]guts.TypeOverride {
91
90
"github.com/coder/coder/v2/codersdk.NullTime" :config .OverrideNullable (config .OverrideLiteral (bindings .KeywordString )),
92
91
// 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
+ },
95
108
})
96
109
97
110
err := gen .IncludeCustom (map [string ]string {