use type config.Account in sherpa api for better typing, and update to latest sherpa lib

typescript now knows the full types, not just "any" for account config.
inline structs previously in config.Account are given their own type definition
so sherpa can generate types.

also update to latest sherpa lib that knows about time.Duration, to be used soon.
This commit is contained in:
Mechiel Lukkien
2024-04-14 17:18:20 +02:00
parent b7d6540d51
commit 4012b72d96
16 changed files with 911 additions and 123 deletions

View File

@ -538,6 +538,8 @@ func parseSelector(t *ast.SelectorExpr, srcTypeName string, sec *section, pp *pa
if pkgName == "time" && typeName == "Time" {
return "timestamp"
} else if pkgName == "time" && typeName == "Duration" {
return "int64"
}
if pkgName == "sherpa" {
switch typeName {
@ -746,8 +748,8 @@ func (pp *parsedPackage) ensurePackageParsed(importPath string) *parsedPackage {
return npp
}
// LookupPackageImportPath returns the import/package path for pkgName as used as
// used in the type named typeName.
// LookupPackageImportPath returns the import/package path for pkgName as used
// in the type named typeName.
func (pp *parsedPackage) lookupPackageImportPath(typeName, pkgName string) string {
file := pp.lookupTypeFile(typeName)
for _, imp := range file.Imports {
@ -758,7 +760,8 @@ func (pp *parsedPackage) lookupPackageImportPath(typeName, pkgName string) strin
return ""
}
// LookupTypeFile returns the go source file that containst he definition of the type named typeName.
// LookupTypeFile returns the go source file that contains the definition of
// the type named typeName.
func (pp *parsedPackage) lookupTypeFile(typeName string) *ast.File {
for _, file := range pp.Pkg.Files {
for _, decl := range file.Decls {