MCPcopy Create free account
hub / github.com/coder/guts / VariableDeclaration

Method VariableDeclaration

bindings/bindings.go:595–629  ·  view source on GitHub ↗
(decl *VariableDeclaration)

Source from the content-addressed store, hash-verified

593}
594
595func (b *Bindings) VariableDeclaration(decl *VariableDeclaration) (*goja.Object, error) {
596 aliasFunc, err := b.f("variableDeclaration")
597 if err != nil {
598 return nil, err
599 }
600
601 var declType goja.Value = goja.Undefined()
602 if decl.Type != nil {
603 declType, err = b.ToTypescriptNode(decl.Type)
604 if err != nil {
605 return nil, fmt.Errorf("alias type: %w", err)
606 }
607 }
608
609 var declInit goja.Value = goja.Undefined()
610 if decl.Initializer != nil {
611 declInit, err = b.ToTypescriptNode(decl.Initializer)
612 if err != nil {
613 return nil, fmt.Errorf("alias type: %w", err)
614 }
615 }
616
617 res, err := aliasFunc(
618 goja.Undefined(),
619 b.vm.ToValue(decl.Name.Ref()),
620 b.vm.ToValue(decl.ExclamationMark),
621 declType,
622 declInit,
623 )
624 if err != nil {
625 return nil, xerrors.Errorf("call variableDeclaration: %w", err)
626 }
627
628 return res.ToObject(b.vm), nil
629}
630
631func (b *Bindings) OperatorNode(value *OperatorNodeType) (*goja.Object, error) {
632 literalF, err := b.f("typeOperatorNode")

Callers 1

Calls 3

fMethod · 0.95
ToTypescriptNodeMethod · 0.95
RefMethod · 0.80

Tested by

no test coverage detected