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

Method constantDeclaration

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

Source from the content-addressed store, hash-verified

764}
765
766func (ts *Typescript) constantDeclaration(obj *types.Const) (*bindings.VariableStatement, error) {
767 val, err := ts.constantValue(obj)
768 if err != nil {
769 return &bindings.VariableStatement{}, err
770 }
771
772 return &bindings.VariableStatement{
773 Modifiers: []bindings.Modifier{},
774 Declarations: &bindings.VariableDeclarationList{
775 Declarations: []*bindings.VariableDeclaration{
776 {
777 Name: ts.parsed.Identifier(obj),
778 ExclamationMark: false,
779 Initializer: val,
780 },
781 },
782 Flags: bindings.NodeFlagsConstant,
783 },
784 Source: ts.location(obj),
785 }, nil
786}
787
788func (ts *Typescript) constantValue(obj *types.Const) (*bindings.LiteralType, error) {
789 var constValue bindings.LiteralType

Callers 1

parseMethod · 0.95

Calls 3

constantValueMethod · 0.95
locationMethod · 0.95
IdentifierMethod · 0.45

Tested by

no test coverage detected