refactor
This commit is contained in:
parent
6e7565284e
commit
57e4b16afc
@ -124,10 +124,10 @@ func (p *TypescriptApiParser) fieldToVal(typ *ast.TypeNode) (types.ValType, erro
|
||||
case "Buffer":
|
||||
return types.TBlob, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("reference type %s is not supported yet", ident.Text)
|
||||
return types.TNoType, fmt.Errorf("reference type %s is not supported yet", ident.Text)
|
||||
}
|
||||
default:
|
||||
return 0, fmt.Errorf("type %s is not supported yet", typ.Kind)
|
||||
return types.TNoType, fmt.Errorf("type %s is not supported yet", typ.Kind)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,28 +1,12 @@
|
||||
package types
|
||||
|
||||
type ValType int
|
||||
type ValType string
|
||||
|
||||
const (
|
||||
TInt ValType = 1
|
||||
TString ValType = 2
|
||||
TBool ValType = 3
|
||||
TBlob ValType = 4
|
||||
TArray ValType = 5
|
||||
TNoType ValType = "" // zero value constant for ValType (please don't use just "" as zero value!)
|
||||
TInt ValType = "int"
|
||||
TString ValType = "string"
|
||||
TBool ValType = "bool"
|
||||
TBlob ValType = "blob"
|
||||
TArray ValType = "array"
|
||||
)
|
||||
|
||||
func (v ValType) String() string {
|
||||
switch v {
|
||||
case TInt:
|
||||
return "int"
|
||||
case TString:
|
||||
return "string"
|
||||
case TBool:
|
||||
return "bool"
|
||||
case TBlob:
|
||||
return "blob"
|
||||
case TArray:
|
||||
return "array"
|
||||
default:
|
||||
panic("unreachable code")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user