Skip to content

Commit

Permalink
encoding/typescript: Use correct cue.Value from thema.Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sam boyer committed May 8, 2023
1 parent 38e454a commit cbcd051
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions encoding/typescript/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func GenerateTypes(sch thema.Schema, cfg *TypeConfig) (*ast.File, error) {
cfg.RootName = strings.Title(sch.Lineage().Name())
}

tf, err := cuetsy.GenerateAST(sch.Underlying().LookupPath(cue.MakePath(cue.Hid("_#schema", "github.com/grafana/thema"))), *cfg.CuetsyConfig)
schdef := sch.Underlying().LookupPath(cue.MakePath(cue.Hid("_#schema", "github.com/grafana/thema")))
tf, err := cuetsy.GenerateAST(schdef, *cfg.CuetsyConfig)
if err != nil {
return nil, fmt.Errorf("generating TS for child elements of schema failed: %w", err)
}
Expand All @@ -80,7 +81,7 @@ func GenerateTypes(sch thema.Schema, cfg *TypeConfig) (*ast.File, error) {
if cfg.RootAsType {
as = cuetsy.TypeAlias
}
top, err := cuetsy.GenerateSingleAST(cfg.RootName, sch.Underlying(), as)
top, err := cuetsy.GenerateSingleAST(cfg.RootName, schdef, as)
if err != nil {
return nil, fmt.Errorf("generating TS for schema root failed: %w", err)
}
Expand Down

0 comments on commit cbcd051

Please sign in to comment.