MCPcopy Index your code
hub / github.com/coder/guts / constantValue

Method constantValue

convert.go:788–804  ·  view source on GitHub ↗
(obj *types.Const)

Source from the content-addressed store, hash-verified

786}
787
788func (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.

Callers 2

parseMethod · 0.95
constantDeclarationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected