(obj *types.Const)
| 786 | } |
| 787 | |
| 788 | func (ts *Typescript) constantValue(obj *types.Const) (*bindings.LiteralType, error) { |
| 789 | var constValue bindings.LiteralType |
| 790 | switch obj.Val().Kind() { |
| 791 | case constant.String: |
| 792 | constValue.Value = constant.StringVal(obj.Val()) |
| 793 | case constant.Int: |
| 794 | // TODO: might want to check this |
| 795 | constValue.Value, _ = constant.Int64Val(obj.Val()) |
| 796 | case constant.Float: |
| 797 | constValue.Value, _ = constant.Float64Val(obj.Val()) |
| 798 | case constant.Bool: |
| 799 | constValue.Value = constant.BoolVal(obj.Val()) |
| 800 | default: |
| 801 | return &bindings.LiteralType{}, xerrors.Errorf("const %q is not a supported basic type, enums only support basic", obj.Name()) |
| 802 | } |
| 803 | return &constValue, nil |
| 804 | } |
| 805 | |
| 806 | // buildStruct just prints the typescript def for a type. |
| 807 | // Generic type parameters are inferred from the type and inferred. |
no outgoing calls
no test coverage detected